I am trying to call:
[System.IO.File]::Delete($folder)
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"
[System.IO.File]::Delete($folder)
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?