Hello,
I am working on an interactive VM deployment script. My code so far queries vCenter and brings lists asking for user choices. It works perfectly as expected when executing one line at a time.
However, I am receiving the following error when running it as a script:
out-lineoutput : The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-tabl
e" command which is conflicting with the default formatting.
+ CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperationException
+ FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
----------------
$Hosts = Get-VMHost -Location $Location | % {$_.Name}
$HostDetails =`
Foreach ($Esx in $Hosts){
$FreeRam = (Get-VMHost -Name $Esx| % {$_.MemoryTotalGB})-(Get-VMHost -Name $Esx| % {$_.MemoryUsageGB})
$FreeCPU = (Get-VMHost -Name $Esx| % {$_.CpuTotalMhz})-(Get-VMHost -Name $Esx| % {$_.CpuUsageMhz})
$Property=@{'Name' = $Esx
'FreeRAM_GB' = "{0:N2}" -f $FreeRAM
'FreeCPU_Ghz' = $FreeCPU}
New-Object -TypeName psobject -Property $Property
}
$HostDetails | Select Name, FreeCPU_Ghz, FreeRAM_GB | FT
----------------
Thank you for your help