Dear power cli guys,
Why i am getting this error when i run the script. how to avoid this ? i am running .net 4.5 with power cli 5.0.
Kindly guide me to solve this thread.
what modification i need to do in this script to avoid this error.
$esx = Get-Content "C:\Users\KVaishali.admin-PC\Desktop\vmlit.txt"
Connect-VIServer $esx -User XXX -Password XXXX
&{
Get-VMHost | Foreach-Object {
$mioThisHostsDStoreInfo = Get-Datastore -VMHost $_ | Measure-Object -Property CapacityGB,FreeSpaceGB -Sum
$dblCapGB = ($mioThisHostsDStoreInfo | ?{$_.Property -eq "CapacityGB"}).Sum ## datastore capacity
$dblFreeGB = ($mioThisHostsDStoreInfo | ?{$_.Property -eq "FreeSpaceGB"}).Sum ## datastore free
Select -InputObject $_ @{n="hostname"; e={$_.NetworkInfo.HostName}},
@{n="IP"; e={$_.name}},
Model,ProcessorType,CpuTotalMhz,CpuUsageMhz,
@{n="CputAvailableMhz"; e={$_.CpuTotalMhz - $_.CpuUsageMhz}},MemoryTotalGB,MemoryUsageGB,
@{n="MemAvailableGB"; e={$_.MemoryTotalGB - $_.MemoryUsageGB}},
@{n="TotalDStoreSizeGB"; e={$dblCapGB}},
@{n="DStoreUsedGB"; e={$dblCapGB - $dblFreeGB}},
@{n="DStoreAvailableGB"; e={$dblFreeGB}},
@{n="Cpu Count"; e={$_.Numcpu}},
@{n="PNicCount"; e={($_.NetworkInfo.PhysicalNic | Measure-Object).Count}}
}
} | Export-Csv -Path "VMs.csv" -NoTypeInformation -UseCulture
With Regards
Anish Kumar.V