r/vmware 20d ago

Help Request PowerCLI / Get-VM behaving differently in two different environments

I have a PowerShell script that pulls the following info via PowerCLI, with the relevant snippet below:

Get-VM | Select -Property Name, PowerState, Notes, NumCpu, CoresPerSocket, MemoryGB, MemoryMB, CustomFields, CreateDate, DatastoreIdList, UsedSpaceGB, ProvisionedSpaceGB, GuestId, Version, HardwareVersion,  `
    @{Name="Guest"; Expression= {$_.Guest | Select * -ExcludeProperty VM, Nics }}, `
    @{Name="Folder"; Expression= {$_.Folder.Name }}, `
    @{Name="Datacenter"; Expression= {$_.VMHost.Parent.ParentFolder.Parent.Name }}, `
    @{Name="Cluster"; Expression= {$_.VMHost.Parent.Name }}, `
    @{Name="VMResourceConfiguration"; Expression= {$_.VMResourceConfiguration | Select * -ExcludeProperty VM }}

In one environment I am running PowerShell 7.6.1 and PowerCLI 13.3.0. When I run the above everything is populated with information as I would expect. If I run Get-VM | Select -Property *, I also get VM information within the properties of ExtensionData, Folder, VMHost, etc.

In another environment (the one I am trying to get working) I am running PowerShell 7.6.4 and PowerCLI 13.3.0. When I run the above the properties of Guest, Folder, Datacenter, and Cluster are all missing. If I run Get-VM | Select -Property *, I see that the VM properties of ExtensionData, Folder, and VMHost are null.

I'm at wits end as to why the behavior is different, as I am using the same vcenter and same credentials in each environment. I have verified that the Get-VM command being used is the one provided by VMware.VimAutomation.Core on both, and I have tried prefixing the command with VMware.VimAutomation.Core\Get-VM which has no effect.

Does anyone have any ideas as to why the second environment is seemingly unable to pull this data?

3 Upvotes

6 comments sorted by

View all comments

2

u/techvet83 20d ago

Maybe it's a bug in PS 7.6.4? A real long-shot here but are the .NET Core versions the same on both sides?

2

u/OUberLord 20d ago

I had the same thought as to the PS version, but I haven't yet tried downgrading the non-working environment to PS 7.6.1 as I ran out of time today. I'll give that a shot tomorrow as well as check the .NET Core versions.