1 / 8

Enhancing PowerShell Cmdlets with ShouldProcess and Impact Level Parameters

This presentation, led by Jeffrey Snover and Jason Helmick, offers an in-depth overview of PowerShell tools essential for developers. Key topics include implementing the `ShouldProcess` parameter and understanding impact levels (Low, Medium, High) for commands that alter system states. Learn to streamline function writing without manual parameter coding and discover how default setting adjustments for `$WhatIfPreference` and `$ConfirmPreference` affect command execution. By utilizing Confirm and WhatIf parameters, developers can confidently manage system changes and avoid unintended consequences.

lisle
Télécharger la présentation

Enhancing PowerShell Cmdlets with ShouldProcess and Impact Level Parameters

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 08 | Tools that make changes Jeffrey Snover | Distinguished Engineer & Lead Architect Jason Helmick | Senior Technologist, Concentrated Technology

  2. Module Overview • Tools that need –confirm and –whatif • Impact Level • Using ShouldProcess • A better example

  3. -Confirm and -Whatif • These parameters should be supported for any commands that changes the system state in any way. • If you’re writing an advanced function, there’s no need to hand code these parameters. • [CmdletBinding(SupportShouldProcess=$True,ConfirmImpact=“High”)] • Ctrl-J for the template

  4. Impact Level • Values for Impact Level are Low, Medium and High • $WhatIfPreference is set to $False by default. If you change is to $True, then all commands that support –Whatif will run as if whatif has been specified. • $ConfirmPreference is set to High by default. If the command impact level is equal to or higher than the preference, then –Confirm is automatically added

  5. Using ShouldProcess

  6. A better example

  7. Questions or comments?

More Related