VM info

 

#================================================================
#
#
#        Tytuł:  VM info
#        Date 2019/02/27
#      
#
#
#====================================================================

add-pssnapin VMware.VimAutomation.Core

#Login with CRED if needed
#
#$vserver = Read-Host -Prompt 'Enter Server name'
#Connect-VIServer $vserver -Credential $creds
#
#
$vCenter  = "Vcenter name or IP"  

Connect-VIServer $vserver


$outputfile = "C:\Batch\VMinfo\" + $vserver + ".csv"
$allvminfo = @()
$vms = Get-Vm

foreach($vm in $vms){
$vminfo = "" | Select Name, IPAddess, OS, Host, Cluster, Datastore, PowerState, SRM, CPUCount, RAMAssigned, ProvisionedSpace, UsedSpace, UnusedSpace, IP

	$vminfo.Name = $vm.Name
    $vminfo.IPAddress = $vm.Guest.IPAddress[0] 
    $vminfo.OS = $vm.Guest.OSFullName 
	$vminfo.Host = $VMHost
    $vminfo.Cluster = $VMCluster.Name
    $vminfo.Datastore = $VMDatastore.Name
	$vminfo.PowerState = $VMPowerState
    $vminfo.SRM = $VMsrm
	$vminfo.CPUCount = $CPUCount
	$vminfo.RAMAssigned = $RAMAssigned
	$vminfo.ProvisionedSpace = $ProvisionedSpace
	$vminfo.UsedSpace = $UsedSpace
	$vminfo.UnUsedSpace = $UnUsedSpace
	$allvminfo += $vminfo
}
$allvminfo | Select Name, Host, Cluster, Datastore, PowerState, SRM, CPUCount, RAMAssigned, ProvisionedSpace, UsedSpace, UnusedSpace, Notes | Export-Csv $outputfile -noTypeInformation
disconnect-viserver -confirm:$false

359 total views, 7 views today