I am trying to call:


from the Powershell ISE (not ISEx86). I am logged in as Domain User that is an Administrator on this machine to which I connect using RDP. I have taken ownership over SysWOW64 folder and granted myself FullControl, for this folder, subfolders and files.

But I still get an "Access Denied" when executing the command above from the Powershell console, which runs under my account "Domain\Administrator".

$xxx =  [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
Write-Host $xxx
$sr =  [Environment]::ExpandEnvironmentVariables("%SystemRoot%")
$sr = Join-Path -Path $sr -ChildPath "\SysWOW64\WindowsPowerShell\v1.0\Modules\"
$folder =  Join-Path -Path $sr -ChildPath "\xxx\Modules"

Exception calling "Delete" with "1" argument(s): "Access to the path 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\xxx\Modules' is denied." At C:\Users\Administrator.CONTOSO\Documents\Visual Studio 2015\Projects\xxx.Powershell.Commandlets\xxx.Powershell.Commandlets\install-module.ps1:9 char:1 + [System.IO.File]::Delete($folder) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : UnauthorizedAccessException

How can I get access?

enter image description here

  • 4
    Only people who really know what they're doing should be deleting system directories. And before you say it, no, you don't qualify, as you weren't even aware that you were using the directory at the time you were trying to delete it. Commented Jun 7, 2016 at 21:43
  • 5
    OP is not good with computer.
    – Wesley
    Commented Jun 8, 2016 at 20:54
  • 1
    Perhaps the on-topic page for this site would be of some interest to you. Helping end users delete directories from their computers isn't even close to what this site is about. Commented Jun 8, 2016 at 21:23
  • 2
    Pretty sure that's off-topic here too.
    – user143703
    Commented Jun 8, 2016 at 22:47
  • 2
    On ServerFault we keep an air of professionalism not found on sites like StackOverflow.
    – Colyn1337
    Commented Jun 8, 2016 at 22:51

1 Answer 1


Erm... You can't delete active files like this. You called a 64 bit powershell instance to delete a module for the 64bit shell. Powershell preloads modules (but doesn't necessarily install them) which locks the module file.

  • I don't want to delete a module, the folder is called "Modules" somewhere below SysWOW64...
    – Legenda
    Commented Jun 7, 2016 at 22:31
  • .. It is a folder I created with powershell console and now I want to delete the same empty folder with powershell again. But I get an "Access Denied".
    – Legenda
    Commented Jun 7, 2016 at 22:39
  • You didn't create it, it was there before you tried. It's there with all 64bit installations.
    – Colyn1337
    Commented Jun 8, 2016 at 15:47
  • `C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules` is a system leaf on 64bit windows systems for the 64bit Powershell.
    – Colyn1337
    Commented Jun 8, 2016 at 21:23
  • That directory is integral to your question and the resolution.
    – Colyn1337
    Commented Jun 8, 2016 at 22:44

Not the answer you're looking for? Browse other questions tagged .