These help files introduce a whole world of specific terms, for example, ‘regular expression comparisons’ and ‘wildcard comparison’. If you want to know more about -Match, -Like and their relatives, then start with PowerShell’s own help thus: Follow-upĪs usual with my scripts, the mission is to get you started. Note 7: I appended code to count the number of WMI classes, this helps to see which variation of my script returns the most items. Perhaps best of all would be to combine -NotLike and -Like. Now it’s over to you experiment with different filters, substitute your ideas for “CIM”, and “_”. Note 6: My mission is always to get you started. Write-Host `n $WMI.count "WMI objects not contain CIM or _" # Version September 2011 tested on PowerShell v 2.0 This example only lists those cmdlets that end with the letters ‘adapter’. Here is a more technical distinction: -Match is a regular expression, whereas -Like is just a wildcard comparison, a subset of -Match. However, if you are pretty sure of most of the letters in the word that you are looking for, then you are better off experimenting with -Match. In a nutshell, if you are thinking, ‘I am probably going to need a wildcard to find this item’, then start with -Like. Example 3: The -Match Comparator Instead of -Like.Example 2: Double Wildcards -Match *Adapter*.Example 1: PowerShell’s -Like Comparator.One day I wanted to create a WMI script using the network adapter, but even using PowerShell I could not find the right properties, so I went back to basics and listed all the cmdlets containing ‘Adapter’. On this page I will explain how to filter data with PowerShell’s -Like comparator. Introduction to PowerShell’s Examples of -Like and -NotLike
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |