我一直在研究如何在网络计算机上找到 SID 的位置,但到目前为止还没有。
我需要搜索我们的网络,并查询所有 PC 的查找是否存在特定的 SID,并为我提供出现此用户 SID 的结果 PC。
任何想法,因为我正在画一个空白。
我一直在研究如何在网络计算机上找到 SID 的位置,但到目前为止还没有。
我需要搜索我们的网络,并查询所有 PC 的查找是否存在特定的 SID,并为我提供出现此用户 SID 的结果 PC。
任何想法,因为我正在画一个空白。
试试这个。获取用户名,转换为 SID,然后在域中的所有计算机中搜索注册表中的该 SID(用户必须登录,否则注册表项不存在)。
$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."
}
}