1 Reply Latest reply on Sep 14, 2016 7:50 AM by Zsoldier

    Report with vm OS running and uptime

    cgiurgiu Lurker

      Hello,

      I'm newbie in PowerCli and I try to combine two kind of extraction data in one csv report.

      The reports is filled only with vm name and uptime. How can I get also de OS version in the report?

       

      $Server = "vmwvc"

      Connect-VIServer -Server $Server -User XXXXX -Password XXXXX

       

      $out = Get-VM | Sort-Object -Property Name |

       

      Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") |

       

          Select -Property Name,

       

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

       

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

         

           Get-Cluster Rom-production-Cluster | Get-VM | ` 

           where {$_.PowerState -eq "PoweredOn"} | ` 

            Get-Stat -Stat sys.uptime.latest -MaxSamples 1 -Realtime | ` 

            select Entity,  

                   @{Name="Boottime"; 

                    Expression={(Get-Date).AddSeconds(- $_.value).ToString("yy/MM/dd HH:mm:ss")}} |

      Export-Csv report.csv -NoTypeInformation -UseCulture

       

      Thank you

        • 1. Re: Report with vm OS running and uptime
          Zsoldier Expert
          vExpert

          Try this:

           

          $Server = "vmwvc"

          Connect-VIServer -Server $Server -User XXXXX -Password XXXXX

            

               Get-Cluster Rom-production-Cluster | Get-VM | `

               where {$_.PowerState -eq "PoweredOn"} | `

                Get-Stat -Stat sys.uptime.latest -MaxSamples 1 -Realtime | `

                select Entity, 

                       @{Name="Boottime";

                        Expression={(Get-Date).AddSeconds(- $_.value).ToString("yy/MM/dd HH:mm:ss")}},

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

           

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

          |

          Export-Csv report.csv -NoTypeInformation -UseCulture