From d2eca7147ec23f56c7ca405937222d447279b884 Mon Sep 17 00:00:00 2001 From: pimentacodit888 <98160028+pimentacodit888@users.noreply.github.com> Date: Fri, 18 Mar 2022 12:01:57 +0100 Subject: [PATCH] feat: Add logging to Get-AzKeyVaultAccessPolicies #271 (#283) Co-authored-by: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> --- .../Scripts/Get-AzKeyVaultAccessPolicies.ps1 | 7 ++++++- .../Arcus.Scripting.KeyVault.tests.ps1 | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 b/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 index b39e79cc..fcb0c505 100644 --- a/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 +++ b/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 @@ -32,9 +32,14 @@ if($keyVault) { storage = $keyVaultAccessPolicy.PermissionsToStorage } + Write-Verbose "Azure Key Vault access policy successfully retrieved for TenantId: $($armAccessPolicy.tenantId) and ObjectId: $($armAccessPolicy.ObjectId)" + Write-Verbose ($armAccessPolicyPermissions | Format-list | Out-String) + $armAccessPolicy | Add-Member -MemberType NoteProperty -Name permissions -Value $armAccessPolicyPermissions $armAccessPolicies += $armAccessPolicy - } + } + + Write-Host "Successfully retrieved Azure Key Vault access policies" } } else { Write-Warning "Azure Key Vault '$keyVaultName' could not be found, please check if the provided vault name and/or resource group name is correct." diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.KeyVault.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.KeyVault.tests.ps1 index 9bdcc5c0..dd6a5518 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.KeyVault.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.KeyVault.tests.ps1 @@ -22,7 +22,7 @@ InModuleScope Arcus.Scripting.KeyVault { Mock Get-AzKeyVault { return [pscustomobject]@{ accessPolicies = @($accessPolicy) } } # Act - $accessPoliciesParameter = Get-AzKeyVaultAccessPolicies -KeyVaultName "key vault" -ResourceGroupName "resource group name" + $accessPoliciesParameter = Get-AzKeyVaultAccessPolicies -KeyVaultName "key vault" -ResourceGroupName "resource group name" -verbose # Assert $accessPolicies = $accessPoliciesParameter.list