none
Conditional -WhatIf RRS feed

  • Question

  • Hi

    I would like to apply the -WhatIf on my script when it runs on DEV/QA environments but not when it runs on PRD,

    How can I have it in a sort of variable?

    ex: something like Set-AdUSer -IDentity "xyz" Add @{aaa=bbb} $myWhatIfFlag

    Thanks,

    JD

     
    Friday, July 19, 2019 10:19 AM

Answers

  • Just add the variable:

    Set-AdUSer -Identity "xyz" Add @{aaa=bbb} -Whatif:$myWhatIfFlag

    Flag is set to $true or $false.


    \_(ツ)_/

    • Marked as answer by junidev Friday, July 19, 2019 8:07 PM
    Friday, July 19, 2019 10:33 AM
    Moderator

All replies

  • Just add the variable:

    Set-AdUSer -Identity "xyz" Add @{aaa=bbb} -Whatif:$myWhatIfFlag

    Flag is set to $true or $false.


    \_(ツ)_/

    • Marked as answer by junidev Friday, July 19, 2019 8:07 PM
    Friday, July 19, 2019 10:33 AM
    Moderator
  • Hello juindev,

    Sure you can do It with "IF" "THEN" conditional commands easily.

    Check this link for more information.

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_if?view=powershell-6


    Hamid Sadeghpour Saleh Microsoft MCT Regional Lead

    hamidsadeghpour.net

    Mark it as answer if your question has solved in order to keep forums updated.


    Friday, July 19, 2019 10:40 AM