Powershell connect to Azure

I needed this today to quickly find a solution as to why a virtual machine was not running, and had to retrieve some info about an application that runs a script.

Start powershell as admin

Set-ExecutionPolicy Unrestricted -force
Install-Module AzureRM

Answer Yes on NuGet. By the way, executionpolicy is not entirely safe, I know, but it works for me right now, because I needed to fix something in the way of.. right now.
You may want to specify differently.

Import-Module AzureRM
Connect-AzureRmAccount

Enter your Azure credentials.

to test the connection, this should return some tenant info:

Get-AzureRmTenant
Get-AzureRmContext

 

By the way, if you want to do something with AzureAD, you may need to do a

Connect-AzureAD

Enter your credentials again, and then do what you want to do, e.g:

Get-AzureADApplication
Get-AzureADContact
Get-AzureADDevice
Get-AzureADGroup

 

etc.

Hope this helps you!

This entry was posted in Azure, powershell. Bookmark the permalink.