Gaprofitt17
Enthusiast
Enthusiast

VMname, Power status and Guest OS

Jump to solution

How would I add Power status on this, and specify I only want powered on VM's in the report?

Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";E={$_.Guest.GuestFullName}} | Export-CSV

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Try something like this

$sView = @{

    ViewType = 'VirtualMachine'

    Property = 'Name','Config.GuestFullName','Guest.GuestFullName','Runtime.PowerState'

    Filter = @{'Runtime.PowerState'='poweredOn'}

}

Get-View @sView |

Select -Property Name,

    @{N='PowerState';E={$_.Runtime.PowerState}},

    @{N="Configured OS";E={$_.Config.GuestFullName}},

    @{N="Running OS";E={$_.Guest.GuestFullName}} |

Export-CSV -Path .\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Try something like this

$sView = @{

    ViewType = 'VirtualMachine'

    Property = 'Name','Config.GuestFullName','Guest.GuestFullName','Runtime.PowerState'

    Filter = @{'Runtime.PowerState'='poweredOn'}

}

Get-View @sView |

Select -Property Name,

    @{N='PowerState';E={$_.Runtime.PowerState}},

    @{N="Configured OS";E={$_.Config.GuestFullName}},

    @{N="Running OS";E={$_.Guest.GuestFullName}} |

Export-CSV -Path .\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

0 Kudos
Gaprofitt17
Enthusiast
Enthusiast

Thanks LucD.. Much appreciated!

0 Kudos