Adminstrator receives PermissionDenied when issuing get-childitem in PowerShell
Solution 1
just a guess; but have you tried taking ownership of the folders on the hd from windows?
- Right-click the folder that you want to take ownership of, and then click Properties.
- Click the Security tab, click Advanced, and then click the Owner tab.
- Click Edit. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
- Click the name of the person you want to give ownership to.
- If you want that person to be the owner of files and subfolders in this folder, select the Replace owner on subcontainers and objects check box.
- Click OK
Solution 2
Try
Get-ChildItem 'e:\Documents and Settings' -Force -Recurse -ErrorAction SilentlyContinue
and report what you find.
Related videos on Youtube
Kelly O'Toole
Updated on September 17, 2022Comments
-
Kelly O'Toole over 1 year
I am trying to backup a drive from a laptop that is defunct. This drive was pulled from the machine and mounted in an external enclosure and connected to a desktop via USB.
Laptop that the drive was pulled from is Windows 7 Pro, and the desktop I connected the laptop drive to is Windows 7 Ultimate.
I am running PowerShell on the desktop to copy everything from the laptop drive, prior to reformatting the laptop drive for re-use. The laptop drive appears as e:\ on the desktop.
When I issue "get-childitem 'e:\Documents and Settings' -force -recurse", I get a PermissionDenied exception on that directory.
Anybody know how I can force a listing of the contents of that directory? I am the administrator after all...
Thanks!
-
Sergiy Kostenko almost 14 yearsCan you even 'Set-Location E:' ? Or does that throw the same exception?
-
Kelly O'Toole almost 14 yearsI can set the location to this drive, yes.
-
Sergiy Kostenko almost 14 yearsWell, vote it up and mark it as the correct answer!
-
Hecter almost 14 yearsCommand line version of this answer: takeown /F "e:\Documents and Settings" /R /D Y