Set-AlCredential

SYNOPSIS

Sets the credential information to the provided credentials.

SYNTAX

Set-AlCredential -Id <String> -Credential <PSCredential> [-SkipVerification]
<!--NeedCopy-->

DESCRIPTION

The Set-AlCredential cmdlet updates an existing credential ID with a new username and password. This cmdlet is designed to securely handle credential updates by using the built-in PSCredential object, ensuring that sensitive information is not exposed in plain text. Verifying that the new credentials work is done as part of this cmdlet unless the -SkipVerification flag is provided.

To use this command, you must provide the following mandatory parameters:

  • The identifier of the credential to be replaced (-Id).
  • The new PSCredential object containing the updated username and password (-Credential). This parameter supports pipeline input.

EXAMPLES

Example 1

PS C:\> Set-AlCredential -Id "QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=" 
<!--NeedCopy-->

This command updates the credentials for the specified ID, QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=. Since no -Credential parameter is provided, PowerShell will automatically display a secure prompt for the user to enter a new username and password. The cmdlet will then verify these credentials before applying the change, and fail if the credentials are invalid.

Example 2

PS C:\> $credentials = Get-AlCredential

PS C:\> Set-AlCredential -Id "QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=" -Credential $credentials
<!--NeedCopy-->

Get-AlCredential provides a secure pop-up to pass in a username and password, and passes these into the $credentials variable. The Set-AlCredential command then updates the credentials for the specified ID, QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=, using the PSCredential object stored in the $credentials variable. It then verifies that the new credentials are valid before applying the change.

Example 3

PS C:\> Set-AlCredential -Id "QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=" -Credential "Administrator"
<!--NeedCopy-->

The Set-AlCredential command updates the credentials for the specified ID, QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=. The -Credential parameter is provided with the value Administrator, which will generate a Powershell credentials request popup with the User Name field populated with this value. The user will have to provide the password before continuing. It then verifies that the new credentials are valid before applying the change.

Example 4

PS C:\> Set-AlCredential -Id "QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=" -SkipVerification
<!--NeedCopy-->

This command updates the credentials for the specified ID, QXBwTGF5ZXJpbmdVc2VyLjEyMzQ=. Since no -Credential parameter is provided, PowerShell will automatically display a secure prompt for the user to enter a new username and password. With the -SkipVerification flag provided, it will force update the new credentials without verifying they will work.

Example 5

PS> $credId = Get-AlCredential | Where-Object { $_.Name -eq "Admin" } | Select-Object -ExpandProperty Id
PS> Set-AlCredential -Id $credId
<!--NeedCopy-->

This example retrieves the ID of the credential named Admin using Get-AlCredential, and stores it in the $credId variable. Set-AlCredential is then used to update the credentials for that specific ID. Since no -Credential parameter is provided, PowerShell will prompt the user to securely enter a new username and password. This allows for interactive credential updates based on a known credential name.

PARAMETERS

-Credential

Specifies the new credentials to update to.

This parameter is mandatory.

Type: PSCredential
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

-Id

Specifies the Id of the intended credentials to be updated by the command.

This parameter is mandatory.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

-SkipVerification

Allows the operation to skip the verification process for the new credentials provided.
Without this switch, the command will fail if the provided credentials are invalid.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

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

None

OUTPUTS

[SetCredentialResult]

Returns the result of the credential update operation, including verification status when -SkipVerification is not specified.

  • Warning [String]
  • WarningDetail [String]
  • Error [ApplicationError]

NOTES

Set-AlCredential