如何使用 Active Directory DirectorySearcher 來尋找所有執行 Windows 10 的電腦?

如何使用 Active Directory DirectorySearcher 來尋找所有執行 Windows 10 的電腦?

我正在嘗試設定一個過濾器,以System.DirectoryServices.DirectorySearcher查找網域內運行 Windows 10 的所有電腦。組合兩個條件的過濾器的語法是什麼?我嘗試過

$Searcher   = New-Object System.DirectoryServices.DirectorySearcher([ADSI]$LDAPProviderPath)
$SearchRoot = New-Object System.DirectoryServices.DirectoryEntry($LDAPProviderPath, "...", "...")

$Searcher.SearchRoot = $SearchRoot

$Searcher.filter="(&(objectCategory=computer)(OperatingSystem=Windows 10))"

如何正確設定過濾器?

答案1

嘗試

"(&(objectCategory=computer) (operatingSystem=*Windows 10*))"

作為 LDAP 過濾器。

相關內容