Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 236824

Re: VM List on conditions to be generated.

$
0
0

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


Viewing all articles
Browse latest Browse all 236824

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>