Get-Credential is a Windows PowerShell command that is used to create and store credentials, such as a username and password, in a secure manner. It is a useful tool for administrators who need to securely store and manage credentials for various tasks. This article will explain the syntax, parameters, inputs, outputs, examples, and tips for using Get-Credential.
Syntax
The syntax for Get-Credential is as follows:
- Get-Credential [-Credential]
Parameters
The parameters for Get-Credential are as follows:
Parameter | Description |
---|---|
-Credential | Specifies a user account that has permission to perform this action. |
-Message | Specifies a message to display that describes the purpose of the prompt. |
-UserName | Specifies the user name for the credentials. |
-Domain | Specifies the domain for the credentials. |
-WhatIf | Describes what would happen if you executed the command without actually executing the command. |
-Confirm | Prompts you for confirmation before executing the command. |
-UseCredentialCache | Specifies that the command uses the credentials in the credential cache. |
Inputs
The inputs for Get-Credential are as follows:
- User name
- Password
- Domain
Outputs
The output of Get-Credential is a PSCredential object.
Examples
The following example shows how to use Get-Credential to create a PSCredential object:
$credential = Get-Credential
The following example shows how to use Get-Credential to create a PSCredential object with a specific user name and domain:
$credential = Get-Credential -UserName "username" -Domain "domain"
Tips
Here are some tips for using Get-Credential:
- Make sure to use a secure password when creating a PSCredential object.
- If you are using Get-Credential in a script, make sure to use the -Confirm parameter to prompt the user for confirmation before executing the command.
- If you are using Get-Credential in a script, make sure to use the -WhatIf parameter to describe what would happen if you executed the command without actually executing the command.
- If you are using Get-Credential in a script, make sure to use the -UseCredentialCache parameter to specify that the command uses the credentials in the credential cache.