Brilliantly simple!
I cannot believe that just moving the array increment up one loop level has resolved the problem.
Just for anyone else thinking of the same thing, the full PS1 file is.
If ((Get-PSSnapin "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "VMware.VimAutomation.Core" } $VCServer = Read-Host "Enter the vCenter server name" $Username= Read-Host "Enter the username" $Password = Read-Host "Enter password" Connect-VIServer $VCServer -User $username -Password $password -port 443 $allvms = @() $vmlist = Get-Vm | where {$_.PowerState -eq "PoweredOn"} ForEach ($vm in $vmlist){ $vmv = $vm | Get-View $vms = "" | Select Name if ($vmv.Config.GuestFullName -match "Windows"){ $vms.Name = $vm.name $allvms += $vms } } $allvms | Out-File "D:\temp\computers.txt" Disconnect-VIserver -Confirm:$false
Geoff