PS C:\Users\rfull> $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
PS C:\Users\rfull> $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
True
PS C:\Users\rfull> PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9709
Line |
9709 | … 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).
Separately but maybe something is busted on my machine:
PS C:\Users\rfull> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
Confirm
Are you sure you want to perform this action?
Performing the operation "Set-ExecutionPolicy" on target "RemoteSigned".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Set-ExecutionPolicy: Could not find file 'C:\Users\rfull\OneDrive\Documents\PowerShell'.
posh-git is installed and execution policy is updated.
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9709
Line |
9709 | … 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).
Name Value
---- -----
PSVersion 7.0.1
PSEdition Core
GitCommitId 7.0.1
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue is caused by controlled folder access being enabled.
This worked for me. Windows Security settings...Virus & threat protection...Virus & threat protection settings...Manage settings...Manage controlled folder access...Allow an app through Controlled folder access...Add an allowed app...Recently blocked apps...select pwsh.exe (C:\Program Files\PowerShell\7) from the list.
This worked for me. Windows Security settings...Virus & threat protection...Virus & threat protection settings...Manage settings...Manage controlled folder access...Allow an app through Controlled folder access...Add an allowed app...Recently blocked apps...select pwsh.exe (C:\Program Files\PowerShell\7) from the list.
I disabled it temporarily. If I had to take a guess it'd be the profile folder under Documents that's being blocked (if that is indeed created during install).
I experienced exactly the same issue. By turning off the controlled folder access under Windows Defender, I was able to install the modules as described by other users. Thanks for the info, really helped.
Most helpful comment
This worked for me. Windows Security settings...Virus & threat protection...Virus & threat protection settings...Manage settings...Manage controlled folder access...Allow an app through Controlled folder access...Add an allowed app...Recently blocked apps...select pwsh.exe (C:\Program Files\PowerShell\7) from the list.