Administrator rights are required to install modules

Recently, I attempted to install the Azurerm module using the “Install-Module Azurerm” PowerShell command, but I encountered the error Administrator rights are required to install modules.”

Administrator rights are required to install modules

Cause of this error

One important thing to note here is that you cannot install PowerShell modules using ‘install-module’ directly in the case of Azure PowerShell functions. This means that if you attempt to install any other modules that are not part of the default modules, it will not allow you to do so. Instead, it will display this error message.

Below is the exact error message I got

install-module: Administrator rights are required to install modules in ‘C:\Program Files\WindowsPowerShell\Modules’. Log on to the
computer with an account that has Administrator rights, and then try again, or install
‘C:\Users\Bijay\Documents\WindowsPowerShell\Modules’ by adding “-Scope CurrentUser” to your command. You can also try running the Windows
PowerShell session with elevated rights (Run as Administrator).
At line:1 char:1

  • install-module azurerm
  • ~~~~~~
    • CategoryInfo : InvalidArgument: (:) [Install-Module], ArgumentException
    • FullyQualifiedErrorId: InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser, Install-Module

You can see it here

Administrator rights are required to install modules

Since the install module points directly to the PowerShell environment directory, and we don’t have access to it, we are getting this error message.

Solution

Follow the steps below to solve this error.

  1. Close the Current PowerShell window or session.
  2. Open PowerShell ISE with Run as Administrator mode.
install-module : Administrator rights are required to install modules

3. Now try rerunning the command; you should encounter no issues this time. Check out the screenshot below.

install-module : administrator rights are required to install modules

Voila !!! This is how you can fix the error “Administrator rights are required to install modules.” Thanks for reading this article !!!

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!