Guy recommends:
A free trial of

Solarwinds Free WebHelpDesk

Install a ticket-based help desk system from SolarWinds. Download your free trial

Windows PowerShell Get-Credential

PowerShell Get-Credential CmdletWindows PowerShell Get-Credential

PowerShell's Get-Credential disappointed me.  I had hoped that this cmdlet would 'capture' my current credentials and encrypt them.

I now realize that Get-Credential has a different purpose, which is to supply a dialog box for us to enter an alternative name and its password.

Topics for PowerShell Get-Credential


PowerShell Get-Credential Example

A typical scenario for Get-Credential, is when you are logged on as ordinary user and you need the credentials of an administrator so that the rest of the PowerShell script will execute successfully.  You may wish to append the -Credential parameter followed by the name of a user account with more rights.

Get-Credential -Credential administrator
# A dialog box should appear populated with administrator
# See screenshot above

Note 1: Most people put the user name "administrator" in double quotes.

Note 2: As with all PowerShell nouns, remember that credential is singular.

Get-Credential As a Foundation for Other Cmdlets

The point of this example, in fact the only reason for using Get-Credential is that the current user has insufficient privileges to run the rest of the PowerShell commands.

# PowerShell Get-Credential example
$Cr = Get-Credential -Credential Administrator
Get-WmiObject Win32_Service -Computer ExchSrv -Credential $Cr

Note 1: If you were already logged on with administrative privileges on the network computer it would be pointless to add the Get-Credential code.

Note 2: This command won't work on your network unless you change -Computer ExchSrv to the hostname of a machine on your network.  Incidentally, if the command still does not work try disabling the firewall.

Guy Recommends: Permissions Analyzer - Free Active Directory ToolFree Permissions Analyzer for Active Directory

I like the Permissions Monitor because it enables me to see quickly WHO has permissions to do WHAT.  When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, takes into account network share access, then displays the results in a nifty desktop dashboard!

Think of all the frustration that this free utility saves when you are troubleshooting authorization problems for users access to a resource.  Give this permissions monitor a try - it's free!

Download Permissions Analyser - Free Active Directory Tool

How to Display a Password as Clear Text

Problem:  To obtain the password in a clear text.

This is not recommended and it's certainly not secure, however, from a scripting point of view the methods are interesting.Windows PowerShell Get-Credential

$ClearPassword = Get-Credential
$ClearPassword.Password | ConvertFrom-SecureString


cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:

Note 3: Homeb0y was the password typed in the box to the right.

Research Parameters for Get-Credential

Get-Help Get-Credential -Full

Note 4: The results reveal that you could use -Message.  The examples explain how to get details from another computer using Invoke-Command with Get-Credential.

Research Methods and Properties for Get-Credential

In truth, there are not as many properties and methods for Get-Credential as for many other PowerShell cmdlets.

$Cred = Get-Credential -Credential Fred
$Cred | Get-Member

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds' Network Performance Monitor will help you discover what's happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds' Network Performance Monitor

Get-Credential -ConsolePromptingWindows PowerShell consolePrompting Credential

The idea of adding this registry setting is twofold, firstly to suppress the credential dialog box, secondly so that you can type the username and password at the command line.

While this technique just would not work for me in Windows Server 2008 PowerShell v 2.0 (CTP3); it DID WORK in WINDOWS 7.

This is one way of adding the registry key:

$key = "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds"
Set-ItemProperty $key ConsolePrompting True

You have to imagine that you are now at the PowerShell command prompt.
When you type:


You should get a line saying:

Supply values for the following parameters:

Then when you type Administrator this is what you see:

Supply values for the following parameters:
User: Administrator
Password for    Administrator

Note 5: I say again, this did not work in Windows Server 2008, even though I could see and control the ConsolePrompting key in the registry at:  HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds. And the value was set to 'True'.

Note 6: The above technique did work in Windows 7.  I kept it simple just launched the PowerShell command line and typed: Get-Credential.  Incidentally, there is no need to type a -ConsolePromting switch.

# This is wrong
Get-Credential -consolePrompting

See ACL tasks ยป

Summary of Windows Get-Credential Cmdlet

The dialog box says it all.  If a PowerShell script needs elevated privileges - administrative rights, then include the Get-Credential code to collect the relevant information.

If you like this page then please share it with your friends


See more PowerShell examples for Shutdown commands

PowerShell Home   • Syntax   • Stop-Computer   • Restart Computer   • Free CSV Import Tool

Get-Credential   • Windows PowerShell   • Windows 8 PowerShell 3.0

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.



Custom Search

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

Windows Management Instrumentation (WMI) is most useful for PowerShell scripting.

SolarWinds have produced this Free WMI Monitor to take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2016 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: