我有一個 PowerShell 腳本,它應該更改檔案的權限:
param([string] $Path)\
$Berechtigung = Get-ACL -Path $Path\
$Berechtigung.SetAccessRuleProtection($true, $true)\
$NEUBerechtigung = New-Object System.Security.AccessControl.FileSystemAccessRule(“TEST\Domain-users”,”Read,ReadAndExecute”,”Allow”)\
$Berechtigung.SetAccessRule($NEUBerechtigung)\
$Berechtigung | Set-Acl -Path $Path
PowerShell 腳本從一個批處理檔案開始,該批處理檔案將資料路徑傳遞給腳本并以管理員身份運行它:
PowerShell.exe -NoProfile -File .\Powershell_komplett.ps1 -path ""C:\_TEST\Erlaubt.txt""\
PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""C:\_TEST\Powershell_komplett.ps1""' -Verb RunAs}"
當我執行批處理檔案時,出現以下錯誤:
該行程不具備此操作所需的“SeSecurityPrivilege”特權。
我怎樣才能繞過這個?
uj5u.com熱心網友回復:
我想限制一個組對檔案的訪問,但我自己在組中。由于我也是我設備的管理員,因此我可以完全訪問該檔案,因此對我來說沒有任何改變。所以我添加了一個我自己不是成員的組,然后它起作用了。謝謝你的幫助
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/520299.html
標籤:电源外壳批处理文件
上一篇:用于回傳傳入變數的批處理腳本語法
