Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Azure/Assign AccessPolicy to KeyVault.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# The ID of the tenant in which the keyVault is located
$tenantId = ''

# The ID of the subscription in which the keyVault is located
$subscriptionId = ''

Expand All @@ -13,14 +16,14 @@ $keyVaultName = ''
[String[]] $permissionsToCertificates = ("get","list","update","create","import","delete","recover","Managecontacts","Getissuers","Listissuers","Setissuers","Deleteissuers","Manageissuers","Purge")

# Login to Azure
Login-AzureRmAccount
Login-AzAccount -SubscriptionId $subscriptionId -TenantId $tenantId

# Select the correct subscription
Select-AzureRmSubscription -SubscriptionId $subscriptionId
Set-AzContext -SubscriptionId $subscriptionId -TenantId $tenantId

try{
# Create/Update an AccessPolicy for the specified user, with the specified permissions.
Set-AzureRmKeyVaultAccessPolicy -VaultName $keyVaultName -ObjectId $userObjectId -PermissionsToSecrets $permissionsToSecrets -PermissionsToKeys $permissionsToKeys -PermissionsToCertificates $permissionsToCertificates -BypassObjectIdValidation
Set-AzKeyVaultAccessPolicy -VaultName $keyVaultName -ObjectId $userObjectId -PermissionsToSecrets $permissionsToSecrets -PermissionsToKeys $permissionsToKeys -PermissionsToCertificates $permissionsToCertificates -BypassObjectIdValidation
Write-Information "Access policy has been created."
}
catch
Expand Down