Save-PSCredential¶
SYNOPSIS¶
Saves a PSCredential object to a file.
SYNTAX¶
Save-PSCredential [-Credential] <PSCredential> [-Path] <String> [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION¶
This function takes a PSCredential object and exports it to a file. If the specified file path does not exist, it creates the necessary directory structure before saving the credential.
EXAMPLES¶
EXAMPLE 1¶
$credential = Get-Credential
Save-PSCredential -Credential $credential -Path 'C:\secure\credential.cred'
Prompts for a username and password, then saves the credential securely to C:\secure\credential.cred
.
EXAMPLE 2¶
$password = ConvertTo-SecureString 'MyPassword' -AsPlainText -Force
$credential = New-PSCredential -Username 'UserName' -Password $password
Save-PSCredential -Credential $credential -Path 'C:\secure\mycreds.cred'
Saves the predefined credential securely to C:\secure\mycreds.cred
.
PARAMETERS¶
-Credential¶
The PSCredential object to be saved.
Type: PSCredential
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
-Path¶
The file path to save the PSCredential to.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
System.Void¶
NOTES¶
RELATED LINKS¶
https://psmodule.io/PSCredential/Functions/Save-PSCredential/