Files
SGU-CredentialProvider/scripts/Uninstall-CredentialProvider.ps1
T

22 lines
1012 B
PowerShell

[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[switch]$RemoveFiles
)
$ErrorActionPreference = 'Stop'
$providerClassId = '{D789CFD8-5AD4-489F-9B83-7EB5D9D09335}'
$installPath = Join-Path $env:ProgramFiles 'SGU\CredentialProvider'
$providerRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\$providerClassId"
$classRegistryPath = "HKLM:\SOFTWARE\Classes\CLSID\$providerClassId"
if ($PSCmdlet.ShouldProcess($providerClassId, 'Unregister the SGU Credential Provider')) {
Remove-Item -LiteralPath $providerRegistryPath -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $classRegistryPath -Recurse -Force -ErrorAction SilentlyContinue
}
if ($RemoveFiles -and $PSCmdlet.ShouldProcess($installPath, 'Remove Credential Provider files')) {
Remove-Item -LiteralPath $installPath -Recurse -Force -ErrorAction SilentlyContinue
}
Write-Output 'The built-in Windows password Credential Provider was not changed.'