Install-Module : Administrator rights are required to install modules in ‘C:\Program files\WindowsPowerShell\Modules’.
Problem: When trying to install a PowerShell module, got an error message “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 ” by adding “-Scope Current User” to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).”
Solution:
Apparently, the PowerShell modules must be installed with the Install-Module cmdlet by running the PowerShell console as Administrator. To resolve the problem, we have two choices:
- Run the PowerShell console by right-clicking on the PowerShell console and choosing “Run as Administrator” and then use Install-Module cmdlet.
- If you don’t have administrator rights, add the “-Scope CurrentUser” switch to the Install-module cmdlet. E.g. “Install-Module AzureADPreview -Scope CurrentUser”
When you use Install-Module with -Scope CurrentUser, it installs the module in the “%USERPROFILE%\Documents\WindowsPowerShell\Modules” folder. You may have to add this path to the “PSModulePath” environment variable to use the cmdlets anywhere.