Remove-SqlCredential

Removes the SQL credential object.

Syntax

Remove-SqlCredential [-Path] <String[]> [-Script] [-InformationAction <ActionPreference>]
 [-InformationVariable <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-SqlCredential [-InputObject] <Credential[]> [-Script] [-InformationAction <ActionPreference>]
 [-InformationVariable <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

The Remove-SqlCredential cmdlet removes a SQL Server credential object. This cmdlet supports the following two modes of operation:

- Specifies the path or location of the credential including the credential name using the Path parameter.

  • Passes a Smo.Credential object to the object using the InputObject parameter.

Examples

Example 1: Remove a SQL credential

PS C:\> emove-SqlCredential -Path "SQLSERVER:\SQL\Computer\Instance\Credentials\MySqlCredential"

This command removes the SQL credential named MySqlCredential using the path specified in the Path parameter.

Example 2: Remove a SQL credential through input pipe

PS C:\> $Cred = Get-SqlCredential -Name MySqlCredential $Cred | Remove-SqlCredential

The command gets the credential object from the Get-Credential cmdlet and then uses the pipeline to pass it to the Remove-SqlCredential cmdlet to remove the SQL credential named MySqlCredential.

Parameters

-Path

Specifies the path of the credential, as an array, on which this cmdlet performs this operation. For instance, SQLSERVER:\SQL\Computer\Instance\Credentials\Credential.

Type:String[]
Required:True
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Script

Indicates that this cmdlet returns a Transact-SQL script that performs the task that this cmdlet performs.

Type:SwitchParameter
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend

Type:ActionPreference
Aliases:infa
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

Specifies an input credential object, as an array. You can use the Get-SqlCredential to get the object.

Type:Credential[]
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False