Thanks Luc , i modified it , still now i am getting this below error :
Connecting to: esxtest-120 Property 'licensed' cannot be found on this object; make sure it exists and is settable.
At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\abc.ps1:12 char:11
+ $HostInfo. <<<< licensed = ($msg[0] -split "State: ")[1]
+ CategoryInfo : InvalidOperation: (licensed:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\abc.ps1:14 char:21
+ $Report | Export-Csv <<<< $ExportFilePath -NoTypeInformation
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand