Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

PackageManagement\Install-Package fails with "Administrator rights are required to install or update." when run as administrator y bug report #656

@yooakim

Description

@yooakim

Steps to reproduce

# Check if I am running in elevated command prompt:
[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
True

Install-Module AzureAd -Scope CurrentUser -Force

Expected behavior

Expect the module to be updated in the current user scope

The same issue has been reported in issue #12777 but that issue was closed as some users reported the problem had to do with Controlled Folder Access.

In my case controlled folder access is off but I still have the issue.

Actual behavior

Get this error. The error message is not correct as I am running from an elevated command prompt. So either the message is wrong or there is a bug.

Install-Module AzureAd -Scope CurrentUser -Force
Install-Package: C:\Users\yooak\OneDrive\Documents\PowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711
Line |
9711 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Administrator rights are required to install or update. Log on to the computer with an account that
     | has Administrator rights, and then try again, or install by adding "-Scope CurrentUser" to your
     | command. You can also try running the Windows PowerShell session with elevated rights (Run as
     | Administrator).

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions