Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

New StoredCredential

Mykhailo Bratukha edited this page Oct 25, 2019 · 2 revisions

New-StoredCredential

Synopsis

Create a new credential in the Windows Credential Store/Vault

Syntax

New-StoredCredential [-Target <String>] [-UserName <String>] [-Password <String>] [-Comment <String>] [-Type <Cred_Type>] [-Persist <Cred_Persist>] [-InformationAction <ActionPreference>] [-InformationVariable <String>] [<CommonParameters>]

New-StoredCredential [-Target <String>] [-UserName <String>] [-SecurePassword <SecureString>] [-Comment <String>] [-Type <Cred_Type>] [-Persist <Cred_Persist>] [-InformationAction <ActionPreference>] [-InformationVariable <String>] [<CommonParameters>]

New-StoredCredential [-Target <String>] [-Comment <String>] [-Type <Cred_Type>] [-Persist <Cred_Persist>] [-Credentials <PSCredential>] [-InformationAction <ActionPreference>] [-InformationVariable <String>] [<CommonParameters>]

Description

Create a new credential in the Windows Credential Store/Vault

Parameters

-Target <String>

Specifies the target of the credentials being added.

Required? False
Position? named
Default value hostname of localhost
Accept pipeline input? false
Accept wildcard characters? False

-UserName <String>

specified the username to be used for the credentials, cannot be used in conjunction with Credentials parameter.

Required? False
Position? named
Default value logged on user
Accept pipeline input? false
Accept wildcard characters? False

-Password <String>

Specifies the password in plain text, cannot be used in conjunction with SecurePassword or Credential parameters.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Comment <String>

Provides a comment to identify the credentials in the store

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Type <Cred_Type>

Type of credential to store, possible values are [GENERIC, DOMAIN_PASSWORD, DOMAIN_CERTIFICATE, DOMAIN_VISIBLE_PASSWORD, GENERIC_CERTIFICATE, DOMAIN_EXTENDED, MAXIMUM, MAXIMUM_EX]

Required? False
Position? named
Default value GENERIC
Accept pipeline input? false
Accept wildcard characters? False

-Persist <Cred_Persist>

sets the persistence settings of the credential, possible values are [SESSION, LOCALMACHINE, ENTERPRISE]

Required? False
Position? named
Default value SESSION
Accept pipeline input? false
Accept wildcard characters? False

-InformationAction <ActionPreference>

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-InformationVariable <String>

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-SecurePassword <SecureString>

provides the password as a secure string, cannot be used in conjunction with Password or Credential parameters

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Credentials <PSCredential>

provides the username and password as a PSCredential object, cannot be used in conjunction with Password, SecurePassword or UserName parameters

Required? False
Position? named
Default value  
Accept pipeline input? true (ByValue)
Accept wildcard characters? False

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

Outputs

Notes

Examples

Example 1

PS C:\> New-StoredCredential -Target server01 -UserName test-user -Password Password1
Flags          : 0
Type           : GENERIC
TargetName     : server01
Comment        : Updated by: Dave on: 23/04/2016
LastWritten    : 23/04/2016 10:48:56
PaswordSize    : 18
Password       : Password1
Persist        : SESSION
AttributeCount : 0
Attributes     : 0
TargetAlias    : 
UserName       : test-user

creates a credential for server01 with the username test-user and password Password1

Example 2

PS C:\> Get-Credential -UserName test-user -Message "password please" | New-StoredCredential -Target Server01

Creates a credential for Server01 with the username and password provided in the PSCredential object from Get-Credential

Related links