Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1036671%22%20slang%3D%22en-US%22%3EPowerShell%20Basics%3A%20How%20to%20Manage%20Azure%20Resources%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1036671%22%20slang%3D%22en-US%22%3E%3CP%3EPowerShell%20automation%20can%20be%20powerful%20when%20harnessed%20correctly.%26nbsp%3B%20Whats%20more%20is%20that%20its%20capabilities%20can%20expand%20well%20beyond%20on-premises.%20To%20get%20started%20on%20this%20journey%2C%20this%20post%20will%20look%20at%20how%20to%20manage%20Azure%20Resources%20via%20PowerShell%20to%20further%20our%20learning%20on%20adoption%20and%20successfully%20set%20the%20foundation%20for%20future%20enablement.%26nbsp%3B%20The%20PowerShell%20module%20installed%20will%20be%20AzureRM%20which%20allows%20for%20management%20of%20both%20Azure%20and%20Azure%20Stack.%20This%20does%20differ%20from%20installing%26nbsp%3B%3CSPAN%3EAz%20modules%20which%20only%20currently%20support%20Azure.%20Further%20details%20surrounding%20this%20can%20be%20found%20%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Finstall-az-ps%3Fview%3Dazps-3.1.0%26amp%3BWT.mc_id%3DITOPSTALK-blog-abartolo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELets%20begin.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3COL%3E%0A%3CLI%3ERun%20PowerShell%20in%20Administrator%20mode%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135894iDF470B1FB4242B46%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22How_to_Force_a_Full_Password_Sync_in_AzureAD_Connect_001.png%22%20title%3D%22How_to_Force_a_Full_Password_Sync_in_AzureAD_Connect_001.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ERun%20PowerShell%20Force%20AzureAD%20Password%20Sync%3C%2FSPAN%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ENext%20run%20the%20following%20command%20to%20verify%20if%20the%20module%20is%20already%20installed%3A%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CPRE%3EGet-Module%20-ListAvailable%20%7C%20Where-Object%20-Property%20Name%20-Like%20%22*Azure*%22%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20Verification%20entails%20that%20no%20modules%20are%20listed%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ENext%20install%20the%20AzureRM%20module%20by%20running%20the%20following%20command%3A%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%0A%3CPRE%3EInstall-Module%20-Name%20AzureRM%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3EEnter%26nbsp%3B%3CSTRONG%3EY%3C%2FSTRONG%3E%20and%20press%20enter%20at%20the%20NuGet%20provider%20prompt%20to%20ensure%20the%20latest%20version%20in%20installed.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20This%20will%20take%20some%20time%20to%20install%3CBR%20%2F%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EAt%20the%20Untrusted%20repository%20prompt%2C%20enter%26nbsp%3B%3CSTRONG%3EY%3C%2FSTRONG%3E%20and%20press%20enter%3A%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159212i443CF88DC02FE9EF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22How_to_Manage_Azure_Resources_via_PowerShell_001.png%22%20title%3D%22How_to_Manage_Azure_Resources_via_PowerShell_001.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EHow_to_Manage_Azure_Resources_via_PowerShell_001%3C%2FSPAN%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20This%20allows%20the%20ability%20to%20install%20packages%20from%20%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2F%3FWT.mc_id%3DITOPSTALK-blog-abartolo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPowerShellGallery.com.%3C%2FA%3E%26nbsp%3B%3C%2FSTRONG%3EThis%20will%20also%20take%20some%20time%20to%20install.%3CBR%20%2F%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ERun%20the%20following%20command%20to%20connect%26nbsp%3Bto%20your%20Azure%20subscription%3A%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%0A%3CPRE%3EConnect-AzureRmAccount%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3EAt%20the%20Untrusted%20Publisher%20prompt%2C%20enter%26nbsp%3B%3CSTRONG%3EA%3C%2FSTRONG%3E%20and%20press%20enter%3A%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159213i6C524338B27973BB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22How_to_Manage_Azure_Resources_via_PowerShell_002.png%22%20title%3D%22How_to_Manage_Azure_Resources_via_PowerShell_002.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EHow_to_Manage_Azure_Resources_via_PowerShell_002%3C%2FSPAN%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%26nbsp%3B%20This%20allows%20the%20ability%20to%20run%20packages%20from%20%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2F%3FWT.mc_id%3DITOPSTALK-blog-abartolo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPowerShellGallery.com.%3C%2FA%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EEnter%20your%20username%20and%20password%20to%20sign%20into%20your%20Azure%20subscription%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20364px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159214i0D5A1E78B10CE4DA%2Fimage-dimensions%2F364x278%3Fv%3D1.0%22%20width%3D%22364%22%20height%3D%22278%22%20alt%3D%22How_to_Manage_Azure_Resources_via_PowerShell_003.png%22%20title%3D%22How_to_Manage_Azure_Resources_via_PowerShell_003.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EHow_to_Manage_Azure_Resources_via_PowerShell_003%3C%2FSPAN%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20Details%20of%20said%20Azure%20subscription%20are%20shown%20once%20authentication%20is%20successful%3CBR%20%2F%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ETo%20verify%20that%20the%20connection%20is%20successful%2C%20run%20the%20following%20command%20to%20list%20the%20subscription's%20resource%20groups%3A%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%0A%3CPRE%3EGet-AzureRmResourceGroup%20%7C%20Select-Object%20-Property%20ResourceGroupName%2CLocation%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3ERun%20the%20following%20command%20to%20add%26nbsp%3B%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2F%3FWT.mc_id%3DITOPSTALK-blog-abartolo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPowerShellGallery.com%3C%2FA%3E%26nbsp%3B%3C%2FSTRONG%3Eas%20a%20trusted%20repository%20to%20quicken%20future%20module%20updates%3A%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%0A%3CPRE%3ESet-PSRepository%20-Name%20PSGallery%20-InstallationPolicy%20Trusted%3CBR%20%2F%3EGet-PSRepository%3C%2FPRE%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CBR%20%2F%3EThat%20completes%20the%20setup%20of%20the%20AzureRM%20module%20in%20PowerShell.%26nbsp%3B%20Future%20blog%20posts%20will%20now%20expand%20on%20specific%20management%20of%20Azure%20Resources%20using%20this%20post%20as%20a%20prerequisite.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1036671%22%20slang%3D%22en-US%22%3E%3CP%3EPowerShell%20automation%20can%20be%20powerful%20when%20harnessed%20correctly.%26nbsp%3B%20Whats%20more%20is%20that%20its%20capabilities%20can%20expand%20well%20beyond%20on-premises.%20To%20get%20started%20on%20this%20journey%2C%20this%20post%20will%20look%20at%20how%20to%20manage%20Azure%20Resources%20via%20PowerShell%20to%20further%20our%20learning%20on%20adoption%20and%20successfully%20set%20the%20foundation%20for%20future%20enablement.%26nbsp%3B%20The%20PowerShell%20module%20installed%20will%20be%20AzureRM%20which%20allows%20for%20management%20of%20both%20Azure%20and%20Azure%20Stack.%20Lets%20begin.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F134944iD72B3B0B8F4E0886%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22PowerShell_Basics.jpg%22%20title%3D%22PowerShell_Basics.jpg%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPowerShell%20Basics%3A%20How%20To%20Manage%20Azure%20Resources%20via%20PowerShell%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1036671%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAnthony%20Bartolo%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1042451%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20How%20to%20Manage%20Azure%20Resources%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1042451%22%20slang%3D%22en-US%22%3E%3CP%3ESurprised%20to%20see%20someone%20from%20MS%20suggest%20AzureRM%20at%20this%20point%2C%20given%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Fnew-azureps-module-az%3Fview%3Dazps-3.1.0%23upgrade-to-az%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erecommendation%20to%20upgrade%20to%20AZ%3C%2FA%3E%20'as%20soon%20as%20possible'%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043991%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20Basics%3A%20How%20to%20Manage%20Azure%20Resources%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043991%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F469611%22%20target%3D%22_blank%22%3E%40JoshuaK%3C%2FA%3E%26nbsp%3B%3CSPAN%3EAzureRM%20will%20continue%20to%20be%20supported%20and%20receive%20bugfixes%20through%20December%202020.%20Microsoft%20also%20advises%20the%20use%20of%20AzureRM%20in%20Azure%20Stack%20for%20the%20time%20being.%20This%20is%20also%20shared%20within%20the%20beginning%20of%20this%20paragraph%20of%20this%20post.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

PowerShell automation can be powerful when harnessed correctly.  Whats more is that its capabilities can expand well beyond on-premises. To get started on this journey, this post will look at how to manage Azure Resources via PowerShell to further our learning on adoption and successfully set the foundation for future enablement.  The PowerShell module installed will be AzureRM which allows for management of both Azure and Azure Stack. This does differ from installing Az modules which only currently support Azure. Further details surrounding this can be found here

 

Lets begin.

 

    1. Run PowerShell in Administrator mode
       
      How_to_Force_a_Full_Password_Sync_in_AzureAD_Connect_001.pngRun PowerShell Force AzureAD Password Sync 
    2. Next run the following command to verify if the module is already installed:
       
      Get-Module -ListAvailable | Where-Object -Property Name -Like "*Azure*"

      NOTE: Verification entails that no modules are listed
       

    3. Next install the AzureRM module by running the following command: 

      Install-Module -Name AzureRM

       

    4. Enter Y and press enter at the NuGet provider prompt to ensure the latest version in installed.

      NOTE: This will take some time to install
       
    5. At the Untrusted repository prompt, enter Y and press enter:
       
      How_to_Manage_Azure_Resources_via_PowerShell_001.pngHow_to_Manage_Azure_Resources_via_PowerShell_001
      NOTE: This allows the ability to install packages from PowerShellGallery.com. This will also take some time to install.
       
    6. Run the following command to connect to your Azure subscription: 

      Connect-AzureRmAccount

       

    7. At the Untrusted Publisher prompt, enter A and press enter:
       
      How_to_Manage_Azure_Resources_via_PowerShell_002.pngHow_to_Manage_Azure_Resources_via_PowerShell_002
      NOTE:  This allows the ability to run packages from PowerShellGallery.com.
       
    8. Enter your username and password to sign into your Azure subscription
       
      How_to_Manage_Azure_Resources_via_PowerShell_003.pngHow_to_Manage_Azure_Resources_via_PowerShell_003
      NOTE: Details of said Azure subscription are shown once authentication is successful
       
    9. To verify that the connection is successful, run the following command to list the subscription's resource groups: 

      Get-AzureRmResourceGroup | Select-Object -Property ResourceGroupName,Location

       

    10. Run the following command to add PowerShellGallery.com as a trusted repository to quicken future module updates:
       
      Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
      Get-PSRepository


That completes the setup of the AzureRM module in PowerShell.  Future blog posts will now expand on specific management of Azure Resources using this post as a prerequisite. 

2 Comments
Frequent Visitor

Surprised to see someone from MS suggest AzureRM at this point, given the recommendation to upgrade to AZ 'as soon as possible'

Microsoft

@JoshuaK AzureRM will continue to be supported and receive bugfixes through December 2020. Microsoft also advises the use of AzureRM in Azure Stack for the time being. This is also shared within the beginning of this paragraph of this post.