Get a security credential object based on a user name and password.
Syntax
Get-Credential [-credential] PSCredential [CommonParameters]
key
-credential
A user name e.g."User01" or "Domain01\User01"
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.
When you enter the command, you will be prompted for a password.
If you omit PSCredential, you will be prompted for a user name and a password.
Examples
Get a credential and save into a variable:
PS C:\>$ss64Cred = Get-Credential
Use the credential object (already stored in a variable) to run a Get-WmiObject command:
PS C:\>Get-WmiObject Win32_DiskDrive -ComputerName Server01 -Credential $ss64Cred
Including a Get-Credential command in a Get-WmiObject command:
PS C:\>Get-WmiObject Win32_DiskDrive -ComputerName Server01 -Credential (get-credential Domain01\User64)
#Please allow me to introduce myself I'm a man of wealth and taste# ~ The Rolling Stones
Related:
Get-AuthenticodeSignature - Get the signature object associated with a file
© Copyright SS64.com 1999-2013
Some rights reserved