FN-GM Posted August 29, 2018 Posted August 29, 2018 Hello, I am wondering if anyone has a working WMI filter that queries what the computer hostname begins with please? For example if the computer hostname is Room-PC01 I would like a filter that picks up Room-PC* Many Thanks
DJ-1701 Posted August 29, 2018 Posted August 29, 2018 Namespace: root\CIMv2 Query: Select * FROM Win32_ComputerSystem WHERE Name LIKE "Room-PC%" You can also do multiple name types like this... Select * FROM Win32_ComputerSystem WHERE ((Name LIKE "Room-PC%") OR (Name LIKE "Room-Laptop%")) 1
FN-GM Posted August 29, 2018 Author Posted August 29, 2018 Thanks. How would I adopt it so it only applies if it doesn't begin with that room number please? Is it the below please? Select * FROM Win32_ComputerSystem WHERE Name NOT LIKE "Room-PC%"
DJ-1701 Posted August 29, 2018 Posted August 29, 2018 Thanks. How would I adopt it so it only applies if it doesn't begin with that room number please? Is it the below please? Select * FROM Win32_ComputerSystem WHERE Name NOT LIKE "Room-PC%" Close Select * FROM Win32_ComputerSystem WHERE NOT Name LIKE "Room-PC%" 1
Arthur Posted August 29, 2018 Posted August 29, 2018 Also, if you want the query to execute faster change the * to Name... Select [color="#FF0000"]Name[/color] FROM Win32_ComputerSystem WHERE NOT Name LIKE "Room-PC%" 1
FN-GM Posted September 3, 2018 Author Posted September 3, 2018 Am I being thick here - This WMI doesn't seem to work? Any suggestions please? Thanks Select Name FROM Win32_ComputerSystem WHERE ((Name LIKE "WA-%") OR (Name LIKE "SA-%") OR (Name LIKE "KA-%"))
Arthur Posted September 3, 2018 Posted September 3, 2018 Select Name FROM Win32_ComputerSystem WHERE ((Name LIKE "WA-%") OR (Name LIKE "SA-%") OR (Name LIKE "KA-%")) Does the following query work for you? Select Name FROM Win32_ComputerSystem WHERE Name LIKE "WA-%" OR Name LIKE "SA-%" OR Name LIKE "KA-%"
FN-GM Posted September 3, 2018 Author Posted September 3, 2018 Is there a quick way to validate it without tampering with the group policy please?
Arthur Posted September 3, 2018 Posted September 3, 2018 Is there a quick way to validate it without tampering with the group policy please? Try this PowerShell... Get-WmiObject -Query 'Select Name FROM Win32_ComputerSystem WHERE Name LIKE "WA-%" OR Name LIKE "SA-%" OR Name LIKE "KA-%"'
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now