RamblingCookieMonster / PSDepend

PowerShell Dependency Handler
MIT License
282 stars 75 forks source link

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

Open JohnLudlow opened 3 years ago

JohnLudlow commented 3 years ago

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