powershell - Search network PCs for user SID -
i have been looking how find location of sid on network computers far nothing.
i need search our network, , query pc's find if specific sid present , give me resulting pcs user sid appears.
any ideas drawing blank.
try this. takes username, converts sid, searches computers in domain sid in registry (user has logged on otherwise registry key doesn't exist).
$user = "username" $sid = get-aduser -identity $user | select -expandproperty sid $computerlist = get-adcomputer -filter * | select -expandproperty dnshostname foreach ($computer in $computerlist){ if (test-connection -computername $computer -quiet -count 1) { $reg = [microsoft.win32.registrykey]::openremotebasekey('users', $computer) if ($reg.opensubkey("$sid")) { write-output "$user found on $computer." } else { write-output "$user not found on $computer." } } else { write-output "$computer unreachable." } }
Comments
Post a Comment