VMware Cloud Community
JMachieJr
Enthusiast
Enthusiast
Jump to solution

Get-VM doesn't return provisioned storage on some VM's

We are having this odd issue where Get-VM will return nothing when trying to get provisioned storage and the host where the VM resides. We have verified the account being used has permissions by logging in to vCenter and we can see everything fine. We are able to browse the datastores and see the VM. We get no errors either. We have even tried our administrator account and still the same issue. We have a ps script that runs to export all the VM's, cpu, memory, storage, and host to a csv. The ones not working right show cpu, memory, and power status but have nothing in the provisioned storage and host fields. Even if we manually do a Get-VM at the command line they still return no information and no error. 

Any ideas?

VCP-DCV | MCP | Linux+ Twitter: @James_Machie_Jr LinkedIn: https://www.linkedin.com/in/jmachiejr
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Can you check if Get-View shows the same issues?
Replace the Get-VM line with

Get-View -ViewType VirtualMachine |
Select Name,@{N='NumCpu';E={$_.Config.Hardware.NumCpu}},
    @{N='MemoryGB';e={$_.Config.Hardware.MemoryMB/1KB}},
    @{N='ProvisionedSpaceGB';E={($_.Summary.Storage.Committed + $_.Summary.Storage.Uncommitted)/1GB}},
    @{N='PowerState';E={$_.Runtime.PowerState}},
    @{N='VMHost';E={(Get-View -Id $_.Runtime.Host).Name}},
    @{N='Date';E={Get-Date}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

That 4 property issue sounds like a familiar PowerShell feature.
I would need to see some code.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JMachieJr
Enthusiast
Enthusiast
Jump to solution

Here is the code with changed server/FQDN names of course. We have the same issue manually running the Get-VM cmdlet against the offending VM's in ps console.

# Load VMware.VimAutomation.Core
Get-Module –ListAvailable VM* | Import-Module

$date = (get-date).ToString('yyyy-MM-dd')

# Run Report against VCENTER03
$cred = Get-VICredentialStoreItem -Host vcenter03.domain.local -File D:\Scripts\report_creds.xml
Connect-VIServer vcenter03.domain.local -User $cred.User -Password $cred.Password
$Filename = "VMReport_vcenter03.csv"
Get-VM | select Name, NumCpu, @{Name="MemoryGB";Expression={$_.MemoryMB/1024}}, ProvisionedSpaceGB, PowerState, VMHost, @{Name="Date";Expression={Get-Date}} | Export-Csv -Path "D:\Scripts\Outbound\$Filename" -NoTypeInformation -UseCulture
Disconnect-VIServer vcenter03.domain.local -Force -Confirm:$false

VCP-DCV | MCP | Linux+ Twitter: @James_Machie_Jr LinkedIn: https://www.linkedin.com/in/jmachiejr
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Nope, that is not showing the issue I had in mind.

Are you by any chance running SRM in that environment?
Might these be the recovery copies?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JMachieJr
Enthusiast
Enthusiast
Jump to solution

No SRM and they are not copies. I also have a ticket open with VMware but I'm not hopeful I'll get help there.

VCP-DCV | MCP | Linux+ Twitter: @James_Machie_Jr LinkedIn: https://www.linkedin.com/in/jmachiejr
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you check if Get-View shows the same issues?
Replace the Get-VM line with

Get-View -ViewType VirtualMachine |
Select Name,@{N='NumCpu';E={$_.Config.Hardware.NumCpu}},
    @{N='MemoryGB';e={$_.Config.Hardware.MemoryMB/1KB}},
    @{N='ProvisionedSpaceGB';E={($_.Summary.Storage.Committed + $_.Summary.Storage.Uncommitted)/1GB}},
    @{N='PowerState';E={$_.Runtime.PowerState}},
    @{N='VMHost';E={(Get-View -Id $_.Runtime.Host).Name}},
    @{N='Date';E={Get-Date}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JMachieJr
Enthusiast
Enthusiast
Jump to solution

I will check on Monday morning when I'm back at work. Thank you for your recommendations.

VCP-DCV | MCP | Linux+ Twitter: @James_Machie_Jr LinkedIn: https://www.linkedin.com/in/jmachiejr
0 Kudos
JMachieJr
Enthusiast
Enthusiast
Jump to solution

@LucD Using the Get-View cmdlet works fine. I get all the info when using that. I don't understand why Get-VM would not work though since we have been using this script for a few years. I guess I'll change it over to using the Get-View cmdlet. Thank you very much for your help.

VCP-DCV | MCP | Linux+ Twitter: @James_Machie_Jr LinkedIn: https://www.linkedin.com/in/jmachiejr
0 Kudos
LucD
Leadership
Leadership
Jump to solution

This seems to confirm that it is a PowerCLI issue and not something in your vSphere environment.

Which PowerCLI version and vSphere version are you using?
This could be a botched PowerCLI installation.

You could try to remove PowerCLI completely and then reinstall it.

You could also try from another station, and check if you have the same issues there.

But an SR would be in any case advisable.
And you don't need a Developer Support contract for PowerCLI support, even if GSS might claim the opposite.

See PowerCLI Support Breakdown


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

JMachieJr
Enthusiast
Enthusiast
Jump to solution

We are running vSphere 6.7 and powercli 6.5. I was just in the process of uninstalling and updating to a newer version. Either way I already have a support request open with VMware and waiting for a response. Thank you again for your help.

VCP-DCV | MCP | Linux+ Twitter: @James_Machie_Jr LinkedIn: https://www.linkedin.com/in/jmachiejr
0 Kudos