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

Optional Credentials

$
0
0

I writing a function, taht I would like to have an optional credential parameter.

By this I mean, taht if no credential is given, the function should "just" use the current users credential, but the function should also allow me to enter specific credentials, in much the same way as several existing cmdlets.

How can I accomplish this in PowerShell?

 

Function Get-Stuff {

Param ($computername,$credential)

Get-WmiObject Win32_Bios -computername $computername -credential $credential

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles