Q. How can I make PowerShell prompt for alternate credentials?
A. To make PowerShell prompt for alternate credentials, run something like
- $cred = Get-Credential username
Doing so will prompt for the credential and store the results in the $cred variable for future use. Note that there's no way to provide the password via the command line, and there's really no secure way to permanently store a username/password combo. (Yes, you could encrypt it, but to read it back in you'd be hard-coding the decryption key, so what's the point?)
Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.