我有一個PowerShell函數,它將啓用對Perflogs文件夾的審計。該功能在英語安裝語言的Windows PC上運行良好。但是當我在丹麥語版本上使用它時,它會失敗,因爲「丹麥語」安裝時不會退出「Everyone」。在丹麥安裝「每個人」被稱爲「全部」Powershell函數中的SID
所以不是每個人使用的話,我想用的SID「S-1-1-0」
S-1-1-0 =所有人/世界link
但由於某種原因,這也行不通。有沒有人有這方面的線索,爲什麼我不能這樣做?
function AddAuditToFile {
param
(
[Parameter(Mandatory=$true)]
[string]$path
)
Get-Acl $path -Audit | Format-List Path,AuditToString | Out-File -FilePath 'file_before.txt' -Width 200 -Append
$File_ACL = Get-Acl $path
$AccessRule = New-Object System.Security.AccessControl.FileSystemAuditRule("S-1-1-0","CreateFiles,Modify,AppendData」,"none","none",」Success")
$File_ACL.AddAuditRule($AccessRule)
$File_ACL | Set-Acl $path
Get-Acl $path -Audit | Format-List Path,AuditToString | Out-File -FilePath 'file_after.txt' -Width 200 -Append}
我這樣調用該函數:
AddAuditToFile "C:\Perflogs"
您是否在嘗試使用SID時收到任何錯誤消息,或者看起來完全沒有做出任何更改? –
''S-1-1-0「' - >'(New-Object System.Security.Principal.SecurityIdentifier([System.Security.Principal.WellKnownSidType] :: WorldSid),$ null)' – PetSerAl
我得到一個錯誤。並且腳本dosnt繼續。 D:不能記住錯誤。 –