coffee in cup with papers glasses and pen in background

Q. How can I make PowerShell prompt for alternate credentials?

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.

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish