Hey All,
Simple scenario.
We have VM's that somewhere in their name have 'TR' to designate them as a training machine.
I have a script that already filters VM's from the Get-VM cmdlet, but I was recently asked to tailor it to grab the TR VM's and make a special note in a log.
I figured this would be simple, but my logic is appearing not to work, just looking for some feedback
Get-VM |
%{
if ($_.Vm.Name -eq '*tr*'){
<ommitted>
But for some reason it doesn't pick up any VM's out of the whole list with 'TR' in them.
Thanks in advance!
Kindest Regards,
ALAN
You can use the -like
if ($_.Vm.Name -like '*tr*')
or -match parameter
if ($_.Vm.Name -match 'tr')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use the -like
if ($_.Vm.Name -like '*tr*')
or -match parameter
if ($_.Vm.Name -match 'tr')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Good morning LucD!
The first one you posted - no dice
The second idea you had worked like a charm!
Thanks as usual for your snappy response,
Kindest Regards,
ALAN
Oops, typo. That should have been asterisk instead of percent sign
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Well ...... I THINK I can forgive you -ALAN