PowerShell_Scripts/WinCreds/Remove-CredentialEntry.ps1

26 lines
693 B
PowerShell

[CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] param (
# Specifies a path to one or more locations.
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="ParameterSetName",
ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[string[]]$EntryName,
[switch]$PassThru
)
begin {
}
process {
foreach( $local:entryname_ in $EntryName ) {
$local:Entry = $entryname_ -replace " ","" -replace "Target:",""
if ($PSCmdlet.ShouldProcess("$Entry", "Remove Credential Entry")) {
cmdkey /del:$Entry | Out-Null
if( $PassThru ) { Write-Output $Entry }
}
}
}
end {
}