-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi,
at the first, thanks for this Script it helps me a lot!
But i found a peculiarity.
In my case i must delete a "Domain User" from a WMInamespace Object and it runs in a Failure:
"Account was not found: (empty)"
get-wmiobject didn't found the Domain User and the $account Var is filled with the correct value.
My workaround:
#132:
# $getparams = @{Class = "Win32_Account"; Filter = "Domain='$domain' and Name='$accountname'" }
# $win32account = Get-WmiObject @getparams
$objUserWMI = New-Object System.Security.Principal.NTAccount("$domain\$accountname")
$objUserWMISID = $objUserWMI.Translate([System.Security.Principal.SecurityIdentifier])
if ($null -eq $objUserWMI) {
throw "Account was not found: $account"
}
#140
#157
# $trustee.SidString = $win32account.Sid
$trustee.SidString = $objUserWMISID.Value
#158
#179
# if ($ace.Trustee.SidString -ne $win32account.Sid) {
if ($ace.Trustee.SidString -ne $objUserWMISID.Value) {
AD-module must not be installed!
Testet on Windows Server (Dektop & Core) 2019 & 2022
Regards Wolfgang
Metadata
Metadata
Assignees
Labels
No labels