Get a Pentest and security assessment of your IT network.

Cyber Security

Block AzureRM PowerShell Module

TL;DR

The AzureRM module is deprecated. This guide shows you how to prevent its use in your environment, ensuring a smooth transition to the Az module and improving cyber security by removing older, potentially vulnerable code.

Steps to Block the AzureRM PowerShell Module

  1. Understand Why You Need to Block AzureRM
    • AzureRM is no longer supported. Microsoft recommends using the Az module for all new scripts and deployments.
    • Continuing to use AzureRM introduces risks, including potential compatibility issues and security vulnerabilities.
  2. Check if AzureRM is Installed
  3. Run the following command in PowerShell to see if the AzureRM module is present:

    Get-Module -ListAvailable AzureRM

    If it returns information about the module, it’s installed. If it says nothing is found, skip to step 4.

  4. Uninstall AzureRM (Recommended)
  5. The best approach is to uninstall the module completely:

    Uninstall-Module -Name AzureRM -AllVersions

    You may be prompted for confirmation. Type ‘Y’ and press Enter.

  6. Prevent Installation via PowerShellGet
  7. To stop users from accidentally installing AzureRM in the future, you can block it in your PowerShellGet settings:

    • Option 1: Block at the Provider Level (Recommended) – This prevents any package from that provider being installed.
    • Set-PSRepository -Name PSGallery -InstallationPolicy Block
    • Option 2: Block a Specific Package – This blocks only AzureRM.
    • Set-PackageSource -Name PSGallery -ProviderName NuGet -Blocked $true
  8. Verify the Block
  9. After blocking, try to install AzureRM again:

    Install-Module -Name AzureRM

    You should receive an error message indicating that the module is blocked.

  10. Update Existing Scripts
  11. This is the most important step. Replace all instances of AzureRM cmdlets with their equivalent Az counterparts. For example:

    • Get-AzureRmVM becomes Get-AzVM
    • New-AzureRmResourceGroup becomes New-AzResourceGroup

    Microsoft provides detailed migration guides to help with this process.

  12. Test Your Updated Scripts
  13. Thoroughly test all updated scripts in a non-production environment before deploying them to production. This ensures that the changes haven’t introduced any unexpected issues.

Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation