Prompting for Secret Passwords via Console

Whenever you need to enter credentials, you can either use Get-Credential or a low- level PS API function like so:

$c = $host.ui.PromptForCredential('Log on', $null, 'test\user', 'target')
$c

You should nNote that the low- level function will allow you to set dialog captions and a custom message. For a custom message, you should replace $null with your message string.

Twitter This Tip! ReTweet this Tip!


Posted Sep 24 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.