1

This is a part of my code

$keyVaults = Get-AzkeyVault | Sort-Object VaultName

    foreach($keyVault in $keyVaults) {

        $kvName = $keyVault.VaultName
        $keyVault | Get-Member

This would result into $keyVault being a PSKeyVaultIdentityItem class, and the output shows

   TypeName: Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultIdentityItem

Name              MemberType Definition
----              ---------- ----------
Equals            Method     bool Equals(System.Object obj)
GetHashCode       Method     int GetHashCode()
GetType           Method     type GetType()
ToString          Method     string ToString()
Location          Property   string Location {get;set;}
ResourceGroupName Property   string ResourceGroupName {get;set;}
ResourceId        Property   string ResourceId {get;set;}
Tags              Property   hashtable Tags {get;set;}
TagsTable         Property   string TagsTable {get;}
VaultName         Property   string VaultName {get;set;}

But, where is my AccessPolicies property. When I do a count I'm getting 0, although in the portal I'm seeing several ...

Kr, Harry

Harry Leboeuf
  • 723
  • 12
  • 30

1 Answers1

1

You get a different result when you use Get-AzKeyVault without specifying a VaultName than when you do. Try this:

$keyVaults = Get-AzkeyVault | Sort-Object VaultName

foreach($keyVault in $keyVaults) {

    $KV = Get-AzKeyVault -VaultName $keyVault.VaultName
    $KV.AccessPoliciesText
}
Mark Wragg
  • 22,105
  • 7
  • 39
  • 68