msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Extend -WhatIf parameter

Open maisarissi opened this issue 3 years ago • 4 comments

Add –WhatIf parameter so users can see what request will be sent to the service without actually sending it.

This effort includes, but may not be limited to just these tasks:

  • [ ] Adding –WhatIf parameter for all commands

  • [ ] Native –WhatIf

  • [ ] Service (AGS) –WhatIf

maisarissi avatar Sep 24 '21 21:09 maisarissi

I just want to add that -WhatIf support is a native feature of PowerShell. It is really helpful for admins learning the commands or doing a dry run before making changes. I have detailed guidance on how to implement it here https://powershellexplained.com/2020-03-15-Powershell-shouldprocess-whatif-confirm-shouldcontinue-everything

KevinMarquette avatar Oct 20 '21 18:10 KevinMarquette

I noticed New-MgGroupMember has the -whatif flag and it works if you handle it directly, however it did not pick up the script $whatifpreference = $true value which is bad. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#whatifpreference

MarkDordoy avatar Jan 20 '22 12:01 MarkDordoy

-WhatIf parameter is already supported on all commands that make changes as stated in https://devblogs.microsoft.com/scripting/weekend-scripter-easily-add-whatif-support-to-your-powershell-functions/. Use Get-Command *-Mg* | where { $_.parameters.keys -Contains "WhatIf" } to see commands that currently supports -WhatIf.

This feature request should:

  • [ ] Extend the current -WhatIf implementation by logging meaning messages about the operation being performed. This is being tracked in https://github.com/Azure/autorest.powershell/issues/213.

peombwa avatar Sep 13 '22 18:09 peombwa

looking at using a directive to address for V2.

ddyett avatar Sep 15 '22 16:09 ddyett

Closed by #1651

peombwa avatar Nov 30 '22 17:11 peombwa