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

Risk mitigation parameters

PowerShell has two risk mitigation parameters called WhatIf and Confirm. They are very useful for testing complicated scripts without risking the code running amok. By appending WhatIf and Confirm, you get a preview of what could have happened without risking the damage. Let's take a real-life example of a file deletion using a wildcard. Consider that there are some files, and you plan to delete them. But you want to ensure that you are deleting the right set of files that you intend to delete. Because you are using a wildcard, the consequences could be very serious. Hence, it is always prudent to ensure that you are not risking the run of the command. Lets assume that you want to remove file*.txt files from some directory; you can use WhatIf something like following:

PS C:\>Get-Childitem C:\somedata\file*.txt -Recurse | Remove-Item -WhatIf

In the example, we used file*.txt (with a wildcard), and the command did not make any permanent change when you appended the command with WhatIf. The command run is just letting us know that if you run it without WhatIf, it is going to delete all those five files. Likewise, you can use Confirm by appending at the end of the command to get a confirmation if the specific file can be deleted or not:

PS C:\>Get-Childitem C:\somedata\file*.txt -Recurse | Remove-Item -Confirm

These two risk mitigation parameters are really powerful when you start rolling out the script to hundreds of servers, and it will help to ease your anxiety a little bit.

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