-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PackageManagement\Install-Package fails with "Administrator rights are required to install or update." when run as administrator #12777
Comments
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. |
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. |
Why was this closed? Is it Microsoft policy that to use PowerShell, controlled folder access must be disabled? Given that an Administrator can install software on a Windows system even with CFA enabled, shouldn't PS Install-* give the same experience? And if not, isn't that a bug that should be fixed? |
Uninstalling my client's A/V entirely, rebooting, checking "Windows Security settings...Virus & threat protection...Virus & threat protection settings...Manage settings...Manage controlled folder access", controlled folders was off, still refuses to upgrade. Uninstall fails too. Sucks to be in this state. |
Experiencing similar issue -- started PS7 as Administrator, entered my credentials to allow Admin access. In PS, I ran the following:
Am getting the following:
Controlled Folders was already disabled in Virus setting. |
Have tried all the options but nothing seems to work for me. Have even tried uninstalling using steps mentioned in link (https://docs.microsoft.com/en-us/powershell/azure/uninstall-az-ps?view=azps-5.6.0). Finally had to delete all the Az folders from C:\Users\kusha\OneDrive\Documents\PowerShell\Modules and copy from C:\Program Files\WindowsPowerShell\Modules which resolved the issue for me. You can run command $env:PSModulePath -split ";" to get all the modules path.
|
I hit this issue as well when trying to install the Azure (Az) module and wasn't able to disable Controlled Folder Access even temporarily because of group policy on my work machine. I was able to work around the issue by installing through a msi instead of going through PSGallery. |
Having same problem here, Controlled Folder Access is already disabled @requilium |
Like @kushal933 - uninstalling all previous versions of a module from My latest run-in with this error occurred while upgrading to PSReadLine 2.2.0-beta.3. I had to close all |
I nixed all the Modules from disk but now receive:
I've tried killing processes, etc, but can't get around it. |
Ensure there are no pwsh/pwsh-preview processes running. Then start pwsh/pwsh-preview with the -noprofile parameter: |
I would choco install sysinternals, and use the |
I would give |
Thanks for the |
Az module falsely throws Admin rights required error:
Private cloud
|
thanks, it works for me. |
I found that powershell was installing files in my Documents directory. I also had OneDrive syncing that directory, which somehow interfered with the powershell process. Deactivating/uninstalling OneDrive fixed my issue. |
PowerShell requires admin privileges for installing or updating PackageManagement modules. See PowerShell/PowerShell#12777
This worled for me too! Thanks a lot. |
Be careful with allowing PowerShell as an exclusion, it basically opens the door for all PowerShell based malware (99%). |
Steps to reproduce
Separately but maybe something is busted on my machine:
Expected behavior
posh-git is installed and execution policy is updated.
Actual behavior
Environment data
The text was updated successfully, but these errors were encountered: