Working around the "You don't currently have permission to access this folder" issue for PowerShell

5.4k views Asked by At

When navigating to C:\Users\%SomeUsername% as an administrator on a Windows 2008 R2 server I get the error You don't currently have permission to access this folder, Click Continue to permanently get access to this folder. Clicking Continue resolves this problem.

If I try the same by PowerShell (e.g. get-childitem 'C:\Users\' -Directory | get-childitem -Force; or some variant), any profiles to which I've not already granted myself access explicitly give the error Access to the path 'C:\Users\%SomeUsername%' is denied.; even with the Force switch included.

Is there a way to "click continue" via PowerShell; i.e. have the system give me access to anything which I don't strictly have access to, though as an administrator on the server can grant myself access to. Ideally this would be done as I access the files (e.g. by a switch on the Get-Item command) rather than having to code something to explicitly go through all files checking and amending permissions.

2

There are 2 answers

0
saftargholi On BEST ANSWER

Make sure about start Powershell Run As Admin if you want always run it as administrator make shortcut from powershell.exe and follow this image : enter image description here

0
JohnLBevan On

My mistake; I hadn't been running the PowerShell session as administrator (i.e. UAC).

  • right click on powershell.exe
  • run as administrator