Exclude server name containing Test

0

I have a script to extract list from vCenter on VMware Tools status daily as below. But It contains also Servers which was meant for Testing where its servers name contain Server-Name-TEST. How can I exclude it out for all server-name contain "TEST"

$VMswithoutRunningTools = $PoweredOnVMs | Get-View | Where-Object {($_.Guest.ToolsStatus -match "toolsNotInstalled") -or ($_.Guest.ToolsStatus -match "toolsNotRunning")} | Select-Object Name,@{Name="Status";Expression={$_.Guest.ToolsStatus}}

Jerry Yeo

Posted 2017-09-12T03:12:23.687

Reputation: 1

You already got selections (Where-Object) just use them to select VMs that don't have a "Test" in their names. E.g. by using -NotLike. – Seth – 2017-09-12T06:17:26.470

if ($VMswithoutRunningTools) { $VMswithoutRunningTools | Where-Object {$_.Name -NotLike 'WLC','PABX'} | ConvertTo-Html | Out-File $outfilepath } – Jerry Yeo – 2017-09-12T06:59:35.717

I make some changes, it is able to reflect 1 varibles but when i try to put another varibles, it do not work anymore. – Jerry Yeo – 2017-09-12T07:00:49.323

If you did change your code, reflect that change in your question please. Comments are really not suitable to post code. It doesn't look like you had a look at how NotLike or Like works. See about_comparison_operators.

– Seth – 2017-09-12T08:55:09.680

No answers