Skip to content

Remove-KeyVaultAccessPolicy

Azure: Removes a Key Vault access policy

param(
	[Parameter(Mandatory = $true)]
	[string]$VaultName,

	[Parameter(Mandatory = $true)]
	[string]$UserPrincipalName
)

try {
	Import-Module Az.KeyVault -ErrorAction Stop
	Remove-AzKeyVaultAccessPolicy -VaultName $VaultName -UserPrincipalName $UserPrincipalName -ErrorAction Stop
	Write-Output "Successfully removed access policy for '$UserPrincipalName' from vault '$VaultName'."
} catch {
	Write-Error $_
	exit 1
}

The name of the Key Vault.

The user principal name (UPN) to remove from the policy.

An interactive directory of PowerShell scripts.