Skip to content

"Domain User" didn´t found #6

@FoXIsNoGood

Description

@FoXIsNoGood

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions