Skip to content

Invoke-PSDepend -Target CurrentUser giving error asking for elevation #130

@JohnLudlow

Description

@JohnLudlow

I am getting this error when using Invoke-PSDepend:

> invoke-psdepend -Confirm:$false -Target CurrentUser
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\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).

The workaround is probably to run from an elevated shell

My PowerShell version:

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

Interestingly I don't seem to get the same behaviour on PowerShell 7.2.0-preview5

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