Search code examples
azurepowershellmicrosoft-graph-api

Can't Install the MS Graph Powershell Extension


I am trying to do some Azure scripting with PowerShell. To do that I need to install the Microsoft.Graph module.

To do that I run the following command:

Install-Module Microsoft.Graph -Scope CurrentUser

After selecting "Y" to continue, it hangs for about 5 seconds. Then it seems to be doing the install. (I see a couple of progress bars.) Then they are replaced with an error that says I need admin rights. Here is a screenshot:

Admin Needed Error when Installing

But I am an Admin, and I am running powershell in Admin mode.

I ran the following command that (supposedly) shows if you are an admin or not, and it returned true:

I am an admin

How can I figure out what is causing this error?


Solution

  • Need to check below:

    1. Check that the PowerShellGet and PackageManagement modules are up to date.

    2. If you are using a proxy, the module installation may be restricted. Check that your proxy settings in PowerShell are accurate.

    3. Try to use -Force parameter with the Install-Module command to avoid conflicts. It will work in some cases.

    4. Certain antivirus or firewall software may interfere with PowerShell module installation in some instances. Disabling them for the duration of the installation could help in determining the issue.

    5. You may also use the Get-ExecutionPolicy -List command to see if there are any extra sources that are blocking the installation of PowerShell modules even if you are running in administrator mode.

    After checked all the above, I tried to install Microsoft.Graph extension in my environment and it worked as expected.

    Install-Module Microsoft.Graph -Scope CurrentUser
    

    enter image description here