From the course: PowerShell: Functions for Advanced Automation
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Use -WhatIf and -Confirm
From the course: PowerShell: Functions for Advanced Automation
Use -WhatIf and -Confirm
- [Instructor] I hope the chair you're sitting in comes with seat belts, because we're about to run right up to the edge of a cliff, and see if we can avoid falling off. If you're following along, make sure your test environment can survive the learning process. I'm going to start by creating a very simple function, and I'm going to call it Get-InTrouble, and open and close the curly braces. Inside the function, I'm going to add one pipeline with two command-lets. Let's start with Get-AdUser, and because I like to be fair to all users, I'm going to add the Filter parameter, with the wild card, to include everyone. Now, just so you know what that includes, let me go ahead and run Get-AdUser, with the filter of the wild car for everything. This member server has the active directory, PowerShell module, installed. If you attempt to run this command-let and get errors, you're going to need to go out and install that module. I go ahead and run it, and that went by pretty quick. I have a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.