Ranadip Dutta
Ranadip Dutta

Reputation: 9133

Wildcard Search in -Filter

Want to have a better understanding of filter option like

This is yielding proper result

Get-WmiObject -Class Win32_Service -Filter "Name = 'vss'"

How to have a wildcard search inside the filter without piping it to the where condition like :

Get-WmiObject -Class Win32_Service -Filter "Name='v*'"

Get-WmiObject -Class Win32_Service -Filter "Name='*v*'"

Get-WmiObject -Class Win32_Service -Filter "Name='v'"

Get-WmiObject -Class Win32_Service -Filter "Name like 'v*'"

Upvotes: 4

Views: 7437

Answers (2)

Rajesh Kumar
Rajesh Kumar

Reputation: 1

Get-WmiObject Win32_Service -Filter "Name LIKE 'MsDtsServer%'"

Upvotes: 0

srw
srw

Reputation: 106

Get-WmiObject -Class Win32_Service -Filter "name LIKE 'vss%'"

It uses WQL for the filtering (% is wildcard)

Which ends up being run as

Get-WmiObject -Query "Select * From win32_service Where name Like 'vss%'"

Upvotes: 8

Related Questions