Hi All,
Was writing a PowerShell custom function, in which input parameter decides the logic inside the script.
Script is somewhat like this ,
get-uptime ($machine, $credentials)
This function when fed with machine name will give uptime. However, there might be cases where I need to enter diff credentials which has access.
To feed different credentials,
get-uptime Machine1 -credentials sometext
Inside script I will make use of " credentials -ne $null "which executes a seperate block with "get-credential" using different credentials.
Without sometext I will get this error message
get-uptime : Missing an argument for parameter 'credential'.
Is there a way I can eliminate "sometext" from above and still be able to perform logical decision inside the script?
To make it more clear,
I want something like this
Get-childitems -recursive
Here we dont have to input anything after recursive.
Where as
Gwmi win32_comptuersystem -computername SomeNam
here SomeNam is required for the above script to work.
Hope its clear.. Please assist.
$Bug