Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180329

get VMs names from Cluster

$
0
0

the below script can provide information regarding VM in a cluster, unfortunatenly the report isn't collected as required

 

# vCenter Login

$vCUser="USER"

$vCPass="PASSWORD*"

 

# LIST OF vCenter

$vCenterIP = "X.X.X.X"

 

foreach ($IPAddress in $vCenterIP){

    # Connection to vCenter

    Connect-VIServer $IPAddress -User $vCUser -Password $vCPass -port 443

}

 

#Variables

$Date = get-date

$Datefile = ( get-date ).ToString("yyyy-MM-dd-hhmmss")

$ErrorActionPreference = "SilentlyContinue"

# Variable to change

$CreateCSV= "yes"

$GridView = "no"

$FileCSV = New-Item -type file ".\PATH\List_VMs_Cluster_vCenterName$datefile.csv"

 

Write-Host "Gathering VMs in Cluster"

    $cluster = Get-Cluster -Name MyvCenter

 

    Get-VM -Location $cluster | where{(Get-VM -Location $folder) -contains $_}

  

#Output

if ($GridView -eq "yes") {

$report | Out-GridView }

 

if ($CreateCSV -eq "yes") {

$report | Export-Csv -LiteralPath $FileCSV -UseCulture -NoTypeInformation

}

 

#file CSV

 

$filename = ".\PATH\List_VMs_Cluster_vCenterName$datefile.csv"

 

 

#Disconnect session from VC

Disconnect-VIserver -Confirm:$false


Viewing all articles
Browse latest Browse all 180329

Trending Articles



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