Tuesday, December 13, 2011

Asking for Credentials


PowerTip of the Day, from PowerShell.com:

When you write functions that accept credentials as parameters, add a transformation attribute! This way, the user can either submit a credential object (for example, a credential supplied from Get-Credential), or simply a user name as string. The transformation attribute will then convert this string automagically into a credential and ask for a password.

function do-something {





'$Credential now holds a valid credential object'



When you run do-something without parameters, it will automatically invoke the credentials dialog.

No comments:

Post a Comment