Skip to content

New-PSCredential

SYNOPSIS

Creates a new PSCredential object.

SYNTAX

__AllParameterSets

New-PSCredential [[-Username] <string>] [[-Password] <Object>] [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

This function generates a PSCredential object using a specified username and password. The password can be provided as a secure string or a plain text string, which will be converted into a SecureString automatically.

EXAMPLES

EXAMPLE 1

New-PSCredential

Prompts the user for a username and password and returns a PSCredential object.

EXAMPLE 2

New-PSCredential -Username 'admin' -Password (ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force)

Creates a PSCredential object for the specified username and password.

PARAMETERS

-Password

Specifies the password for the PSCredential object. Accepts a secure string or plain text.

Type: System.Object
DefaultValue: (Read-Host -Prompt 'Enter Password' -AsSecureString)
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Username

Specifies the username for the PSCredential object.

Type: System.String
DefaultValue: (Read-Host -Prompt 'Enter a username')
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Management.Automation.PSCredential

{{ Fill in the Description }}

NOTES