SysWOW64 访问被拒绝(Windows Server 2012 标准版)

Leg*_*nds -7 security powershell access-control-list windows-server-2012 powershell-v3.0

我想打电话:

[System.IO.File]::Delete($folder)
Run Code Online (Sandbox Code Playgroud)

来自 Powershell ISE(不是ISEx86)。我以域用户身份登录,该用户是我使用 RDP 连接到的这台机器上的管理员。我已经拥有 SysWOW64 文件夹的所有权,并授予自己 FullControl 权限,用于此文件夹、子文件夹和文件。

但是,在我的帐户“域\管理员”下运行的 Powershell 控制台执行上述命令时,我仍然收到“拒绝访问”。

$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)
Run Code Online (Sandbox Code Playgroud)

使用“1”参数调用“Delete”的异常:“拒绝访问路径‘C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\xxx\Modules'。” 在 C:\Users\Administrator.CONTOSO\Documents\Visual Studio 2015\Projects\xxx.Powershell.Commandlets\xxx.Powershell.Commandlets\install-module.ps1:9 char:1 + [System.IO.File]::删除($文件夹)+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException +fullyQualifiedErrorId : UnauthorizedAccessException

我如何获得访问权限?

在此处输入图片说明

Col*_*337 5

呃...你不能像这样删除活动文件。您调用了 64 位 powershell 实例来删除 64 位 shell 的模块。Powershell 预加载模块(但不一定安装它们),从而锁定模块文件。