Adminstrator receives PermissionDenied when issuing get-childitem in PowerShell

13,356

Solution 1

just a guess; but have you tried taking ownership of the folders on the hd from windows?

  1. Right-click the folder that you want to take ownership of, and then click Properties.
  2. Click the Security tab, click Advanced, and then click the Owner tab.
  3. Click Edit. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
  4. Click the name of the person you want to give ownership to.
  5. 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.
  6. Click OK

Solution 2

Try

Get-ChildItem 'e:\Documents and Settings' -Force -Recurse -ErrorAction SilentlyContinue

and report what you find.

Share:
13,356

Related videos on Youtube

Kelly O'Toole
Author by

Kelly O'Toole

Updated on September 17, 2022

Comments

  • Kelly O'Toole
    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
    Sergiy Kostenko almost 14 years
    Can you even 'Set-Location E:' ? Or does that throw the same exception?
  • Kelly O'Toole
    Kelly O'Toole almost 14 years
    I can set the location to this drive, yes.
  • Sergiy Kostenko
    Sergiy Kostenko almost 14 years
    Well, vote it up and mark it as the correct answer!
  • Hecter
    Hecter almost 14 years
    Command line version of this answer: takeown /F "e:\Documents and Settings" /R /D Y