Import certs in multiple keyvaults

Occasional Visitor
Hi,
tryin to import nav.pfx cert in multiple keyvaults across subscription , getting below error 
Import-AzKeyVaultCertificate: untitled:Untitled-1:7:8
Line |
7 | Import-AzKeyVaultCertificate -VaultName $vault -Name "navneet" …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Array may not be empty or null. (Parameter 'rawData')
 
need help to fix it 
 
I am using below code
---------------------
$subs = Get-Content -Path ./Desktop/sub.txt
foreach($sub in $subs){
Set-AzContext -Subscription $sub
$vaults = Get-AzKeyVault -ResourceGroupName $vault.ResourceGroupName -VaultName $vault.VaultName
foreach($vault in $vaults){
$Password = ConvertTo-SecureString -String "12345" -AsPlainText -Force
Import-AzKeyVaultCertificate -VaultName $vault -Name "cert" -FilePath "./Desktop/nav.pfx" -Password $Password
 
}
}

 

0 Replies