Microsoft Azure: Azure PowerShell – ForbiddenError: The server failed to authenticate the request.

Hey, so if you are getting this error I’ll walk you through the easiest ways to remedy it.


PS C:\> Get-AzureVM
Get-AzureVM : ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and i
s associated with this subscription.
At line:1 char:1
+ Get-AzureVM
+ ~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand


Set-AzureSubscription : ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.

The solution often is easier then you’d think, just like how browsers have their cache so does your Microsoft Azure PowerShell so you’ll want to input this:



This will clear your current Azure profile.

You should also consider deleting the content of this folder:

C:\Users\%USERNAME%\AppData\Roaming\Windows Azure Powershell

After which you can run

Add-AzureAccount / Login-AzureRMAccount

and then you can execute any Azure PowerShell commands that you’d like to run. For a more detailed walkthrough check my article on connecting and managing Microsoft Azure via PowerShell.


PS: If you are still getting errors, you should check whether the mode you are running in is incorrect you can input 

Switch-AzureMode AzureResourceManager

Important to note that “Switch-AzureMode” is deprecated and will be removed in a future release. However doing so seemed to import the certificate and removed the “ServiceManagement” modules that were loaded with this install and installed the correct certificate.

So now to see if it’s working we can run Get-AzureVM or Get-AzureRMvm

which outputs:




As always, you can follow me on Twitter at @UlvBjornsson or follow me on here, if you have tips for articles you’d like to read or topics you want to hear more about, hit me up.


Microsoft Azure: Configuring auto-shutdown

So, in Azure you pay for what you use. If it’s on (or if it is allocated), you are paying for it, until it is deallocated.

So what can we do to save costs? We can configure automatic shutdown.


So if we enter “Auto-shutdown” on the left panel in the VM:


So let’s enable it, and set our preferred time for shutdown. Ensure that you have configured the timezone correctly so that it shutsdown when you expect it to.



There you go, you’ve configured automatic shutdown on a schedule.

Next up, we’ll be looking at runbooks and the possbility of turning your virtual machines off, but also on again on a fixed schedule.

Stay tuned for more, and always you can reach me here or over on twitter at @UlvBjornsson.

If you are curious about the Azure exam 70-533, you can check out my write up on it over here.

Until next time!