I'm getting the following error:
PS>TerminatingError(Get-VMHost): "A positional parameter cannot be found that accepts argument 'State'
This is triggered by the following code:
Get-View -ViewType HostSystem -Property 'Name', 'Config.Product', 'Hardware.SystemInfo' | select Name,
@{N="ESXi Version";E={$_.Config.Product.FullName}},
@{N="Build";E={$_.Config.Product.Build}},
@{N="vCenter";E={$vCenter}},
@{N="Datacenter";E={Get-Datacenter -VMHost $_.Name}},
@{N="DVSwitch";E={Get-VDSwitch -VMHost $_.Name}},
@{N="Cluster";E={Get-Cluster -VMHost $_.Name}},
@{N="State";E={Get-VMHost -Name $_.Name State}},
@{N="Server Model";E={$_.Hardware.SystemInfo.Vendor+ " " + $_.Hardware.SystemInfo.Model}},
@{N="Serial Number";E={$_.Hardware.SystemInfo.OtherIdentifyingInfo[0].IdentifierValue+ " "
}} | Export-Csv -NoTypeInformation -UseCulture -Append -Path $Outfile
This is the environment information on the system where it got the error:
Machine: hostname-removed (Microsoft Windows NT 6.1.7601 Service Pack 1)^M
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
-noe -c . "C:\Program Files (x86)\VMware\Infrastructure\vSphere
PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"^M
Process ID: 177960^M
PSVersion: 5.0.10586.117^M
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0.10586.117^M
BuildVersion: 10.0.10586.117^M
CLRVersion: 4.0.30319.42000^M
WSManStackVersion: 3.0^M
PSRemotingProtocolVersion: 2.3^M
SerializationVersion: 1.1.0.1^M
I tried the same script in my lab, and it ran fine, although for some reason it didn't print the detailed information as it did above. Anybody have any thoughts as to why I'm seeing this? Note that I'm still on some older versions of vSphere, i.e. 5.5 and 6.0, so I don't think upgrading to PowerCLI 6.5.x will work.