PowerShell Credentials for Cmdlets – Get-Credential

Posted on Wednesday, August 4th, 2010 at 12:02 am in

I’m sorry that i was so quite the last few weeks. There was a lot to do. Furthermore I tried to enjoy the sun as often as possible 😉 But I’ll still try it hard to post more frequently.

Just a short PowerShell ÔÇôTrick which will save you a lot of time 😉

A lot of Cmdlets need the right credentials to perform a action. Especially with W2008R2 and the AD-Cmdlets or with Exchange 2010 this is handy. So you can either type your username/password every time, or just save it to a variable.

$cred = Get-Credential

After hitting Enter a Pop-Up appears where you can enter your credentials. They will be saved within the variable

The input isn’t validated. It’s just saved within the variable for later processing. And don’t worry, the password isn’t saved as clear text 😉

You can also fill the prompt with a username by using “Get-Credential <Username>”. This is maybe helpful when using that in a script.

You can also use this Pop-Up Mechanism directly in a command.

So have fun playing around with PowerShell 😉

May the Shell be with you J

You might also be interested in


Add your comment

  1. ultrasound technician - August 6, 2010 at 8:07 pm

    Great information! IÔÇÖve been looking for something like this for a while now. Thanks!

  2. John Hamelink - August 30, 2010 at 9:17 pm

    What makes you an expert?…

    I found your entry interesting thus I’ve added a Trackback to it on my weblog :)…

Leave a Reply

Leave A Comment