get-service from multiple computers from the AD

by Sep 19, 2012

Hi,

Im back with another formating issue =/

the code below selects all computers from a single OU, picks up their name and then tests the connection to them and searches for the VM ware tools service

$VMs = Get-ADComputer -SearchBase "OU=blabla,OU=Workstations,OU=Organization,OU=Data,DC=bla,DC=bla" -Filter * | Select-Object -Property name

foreach ($vm in $VMs) {

Test-Connection -ComputerName $vm -Count 1 | foreach {( Get-Service -displayname 'VMware Tools Service' -ComputerName $_.IPV4Address ) } | Format-Table -Property machinename, status, displayname, name -AutoSize

}

The problem i am having is in the formatting, again… if i pipe the output to a file its filled with spaces after the computer name, thus posing a problem in the "foreach" part of the script

IF i edit that file of computernames and remove all the blank spaces after the computernames it works

Any ideas?