I'm trying to use the ^ $ anchors to get an exact match with the -filter option. Below is my syntax.
Keep in mind $hostname is a variable containg the name of a VM ... NameOfVM is actually a name of VM NOT a variable.
Without Anchors - returns multiple values
$vm = Get-View -ViewType virtualmachine -Filter @{"Guest.HostName"="$hostname"}
With Anchors - returns nothing
$vm = Get-View -ViewType virtualmachine -Filter @{"Guest.HostName"="^$hostname$"}
With Anchors - returns nothing
$vm = Get-View -ViewType virtualmachine -Filter @{"Guest.HostName"="^hostname$"}
Withoug Variable - Works
Get-View -ViewType virtualmachine -Filter @{"Guest.HostName"="^$NameOfVM$"}
So in short.. the anchors work when i DO NOT use a variable in the filter ... but fail when using a variable. This makes it impossible for me to loop with.
Any ideas?
Thanks,
JD