Wednesday, June 7, 2017

How to make a parameter mandatory in powershell.

How to make a parameter mandatory in powershell.

Enter this at the start of your script.

param(
            [Parameter(Mandatory=$true)]
            [string]$Server
           )

A very good explanation and additional ways to do it is here.

https://blogs.technet.microsoft.com/heyscriptingguy/2011/05/22/use-powershell-to-make-mandatory-parameters/

No comments:

Post a Comment