Reputation: 75
I am running this command on Windows 2012 server R2 with Azure Powershell
I am using following code for setting azure subscription
C:\PS>$subID = <Subscription ID>
C:\PS>$thumbprint = <Certificate Thumbprint>
Getting certificate thumbprint contain using
C:\PS>$myCert = Get-Item cert:\\CurrentUser\My\$thumbprint | Out-String
C:\PS>Set-AzureSubscription –SubscriptionName $subID –SubscriptionId $subID –Certificate `"$myCert`"
But it is failing with following error
Set-AzureSubscription : Cannot bind parameter 'Certificate'. Error: can't convert illegal characters
I have also tried with following code
C:\PS>$myCert = Get-Item cert:\\CurrentUser\My\$thumbprint
C:\PS>Set-AzureSubscription –SubscriptionName $subID –SubscriptionId $subID –Certificate $myCert
Still it is failing with error Cannot bind parameter 'Certificate'
Thanks in advance
Upvotes: 0
Views: 763
Reputation: 2847
You should stop using certificates for Azure PowerShell auth and start using AAD. This works for both the Azure Service Management and Azure Resource Manager modes of PowerShell.
Add-AzureAccount Select-AzureSubscription ... Set-AzureSubscription ...
and you're done - never having to worry about certificates again.
Upvotes: 2
Reputation: 5496
You should use:
Get-Item Cert:\CurrentUser\
(i.e. not cert:\\CurrentUser\ with two back slashes)
Upvotes: 0