WMI Filtering to select a group of computer

Ming Cheung 426 Reputation points
2023-08-10T15:33:31.1133333+00:00

I want to apply WMI filtering in GPO to a group of computers only

I test the query, it is unable to select the group of computers, always only show the DC itself

get-wmiobject -query 'select * from win32_computersystem'

and i just test to applying [ select * from win32_computersystem where name='PC01' ]

but it works.

how to verify or show what exactly select and apply?

thanks

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wesley Li (Shanghai Wicresoft Co., Ltd.) 236 Reputation points
    2023-09-19T10:00:01.8766667+00:00

    Hello

    To apply a WMI filter to a group of computers, you can use the Win32_ComputerSystem class and the Name property in your WMI query. However, it seems like you’re having trouble getting the query to select the correct group of computers.

    Here are some steps you can follow to troubleshoot this issue:

    Verify the Computer Names: Ensure that the computer names you’re using in your WMI query match exactly with the names of the computers in your domain. Computer names are case-sensitive.
    
    Test Your WMI Query: You can test your WMI query on an individual computer before applying it to a group. For example, you can use the Get-WmiObject cmdlet in PowerShell to run your WMI query. Here’s an example:
    
    Get-WmiObject -Query "SELECT * FROM Win32_ComputerSystem WHERE Name = 'PC01'"
    
    This command should return information about the computer named ‘PC01’. If it doesn’t return any results, then there might be an issue with your WMI query or the computer name.
    
    Use a Loop to Query Multiple Computers: If you want to apply your WMI filter to a group of computers, you can use a loop in PowerShell to run your WMI query on each computer. Here’s an example:
    
    $computers = 'PC01', 'PC02', 'PC03'  # Replace with your computer names
    
    foreach ($computer in $computers) {
    
        Get-WmiObject -ComputerName $computer -Query "SELECT * FROM Win32_ComputerSystem WHERE Name = '$computer'"
    
    }
    
    This script will run your WMI query on each computer in the $computers array.
    
    Check for Errors: If there are any errors when running your WMI query, they should be displayed in the PowerShell console. These errors can help you troubleshoot any issues with your WMI filter.
    
    Remember, any changes made by Group Policy may take some time to propagate throughout your network. You can force an immediate update by running gpupdate /force on the affected computers.
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.