Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 231085

Re: get-view

$
0
0

Hello-

 

Good.

 

As for why using -Filter for Name only returns four of those six VMs:  this is because of the fact that the value for the Name key is a regular expression pattern, and that some of your VMs have characters that mean something different in the context of a regular expression.  Specifically, the parenthesis are grouping construct characters in the regular expression context.  You can read about such things at MSDN Regular Expression Reference.

 

You can see the behavior in the example:

PS C:\> "aus-dc (2)" -match "aus-dc (2)"
False

 

So, if you wanted to actually match by name, then you could escape those special characters in the string manually, or use the Escape() static method of the System.Text.RegularExpressions.Regex .NET class.  The behavior is then probably more like what you are expecting:

PS C:\> "aus-dc (2)" -match [Regex]::Escape("aus-dc (2)")
True

 

Adding the [Regex]::Escape() in the Filter like "...-Filter @{'Name' = [Regex]::Escape($vmname.name)}" would get closer to the behavior that you are expecting (but, again, the regular expression that you are using may match longer strings that contain the pattern that you are specifying).

 

There are other, more precise ways to get the View objects.  I'll reply to your latest post here with more info on that.


Viewing all articles
Browse latest Browse all 231085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>