Author Posts

July 20, 2016 at 8:45 pm


Wondering why I am getting prompted by the GUI -whatif for the following one-liner where it is not explicitly set?

foreach ($user in $Users) {Remove-ADUser $user.samAccountName -Credential $creds}

...because I am attempting to delete 400 Users but am getting prompted for each of them.

thank you

July 20, 2016 at 9:08 pm

Commands have an attribute called ConfirmImpact. By default, any command with a ConfirmImpact of 'High' will prompt you unless you explicitly tell PowerShell not to (such as with -Confirm:$false).

July 20, 2016 at 9:32 pm

Dave, worked a charm and many thanks for the speedy reply. Much appreciated

July 21, 2016 at 9:06 am

Just to be 100% accurate you're getting prompted for a confirmation not a whatif. -Whatif parameter just produces a statement saying it would do something not a prompt to confirm an action

July 21, 2016 at 5:32 pm

100% understood Richard and thank you for clarifying.