Discovering Impact Level

by Mar 23, 2010

In a previous tip, you learned how to use $ConfirmPreference to get a warning before a cmdlet actually changes your system. This was based on the impact level that a cmdlet declares. There is no obvious way to determine the impact level of cmdlets. Here is a line that will get you that information so you can see how severe the action is that a given cmdlet will take:

Get-Command -CommandType Cmdlet |
ForEach-Object {
$_.ImplementingType.GetCustomAttributes($true) |
Where-Object { $_.VerbName -ne $null } |
Select-Object @{Name='Name' Expression={'{0}-{1}' -f $_.VerbName, $_.NounName}}, ConfirmImpact
} |
Sort-Object ConfirmImpact -Descending

Twitter This Tip! ReTweet this Tip!