Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

checking command line arguments passed to PS script are present...

$
0
0

Hi,

I am very new to using Power Shell and I am stumped...

I need to pass 4 arguments to my PS script and I am not sure of the most efficient way of checking that they have all be specified on the command line...

 

$devicename=$args[0]

$ipaddress=$args[1]

$username=$args[2]

$password=$args[3]

 

I need the script to exit if one or more value is missing, preferably with a message saying that there is a problem... If all values are present the script should continue to process...

I am sure this is very simple - but I just don't know how to go about sorting it...

Any help will be most appreciated...

Thanks in advance

 

Martin


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images