![如何使用 Active Directory DirectorySearcher 來尋找所有執行 Windows 10 的電腦?](https://rvso.com/image/1684431/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20Active%20Directory%20DirectorySearcher%20%E4%BE%86%E5%B0%8B%E6%89%BE%E6%89%80%E6%9C%89%E5%9F%B7%E8%A1%8C%20Windows%2010%20%E7%9A%84%E9%9B%BB%E8%85%A6%EF%BC%9F.png)
我正在嘗試設定一個過濾器,以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 過濾器。