Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
AWS Tools for PowerShell 6

You're reading from   AWS Tools for PowerShell 6 Administrate, maintain, and automate your infrastructure with ease

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher
ISBN-13 9781785884078
Length 372 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ramesh Waghmare Ramesh Waghmare
Author Profile Icon Ramesh Waghmare
Ramesh Waghmare
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. PowerShell Essentials FREE CHAPTER 2. The AWS Overview 3. Installing PowerShell Core and AWS Tools 4. AWS Identity and Access Management 5. AWS Virtual Private Cloud 6. AWS Elastic Compute Cloud 7. AWS Simple Storage Service 8. Elastic Load Balancer 9. Auto Scaling 10. Laying Foundation for RDS Databases 11. DB Instance Administration and Management 12. Working with RDS Read Replicas 13. AWS Elastic Beanstalk 14. AWS CloudFormation 15. AWS CloudWatch 16. AWS Resource Auditing

Building parameterized script

When you start building script for automation that can be used by yourself and others repeatedly for doing some task, building parameterized script is the key. In PowerShell, it is very easy to build the parameterized script using just a simple param keyword in the script file. You may have solved the problem using individual cmdlets, and you now want that one to be used repeatedly for building an automation. Let's review the following script for a better understanding of using parameters:

I created a file called DiskInfo.ps1 in the D:\scripts directory. This script provides you with free GB available on the drive that you pass to this script. I am using Get-CimInstance to get me the computer name and free GB. The param keyword at the top of the script can be seen. You might just need to get a feeling of writing that syntax and nothing more. To make the drive letter mandatory, I used a keyword called Mandatory=$true. Once you saved the file, the script can be run as follows:

PS :\D>.\DiskInfo.ps1 -Drive C:

The beauty of the script is that when you start hitting the tab after the script name on the command prompt, it starts displaying you the parameters that can be passed to the script, which is amazing. This is the way you start building a new set of cmdlets for you. There is nothing else that needs to be done to build your own cmdlets.

You have been reading a chapter from
AWS Tools for PowerShell 6
Published in: Aug 2017
Publisher:
ISBN-13: 9781785884078
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime