VMware Cloud Community
Nomi_epc
Enthusiast
Enthusiast
Jump to solution

Looking for a Script which contains OS information in each resource pool in a multi cluster environment

LucD

I am Looking to modify a below script which also contains OS information in each resource pool in a multi cluster environment. OS type, details as much OS information as possible on each VDC in a v cloud environment. i Want to include the OS info in the below script. what sort of changes i need to make in the below script. Please help. Thanks in Advance.

$report = @()

foreach($cluster in Get-Cluster){

    foreach($rp in Get-ResourcePool -Location $cluster){

        foreach($vm in (Get-VM -Location $rp)){

            $report += Get-HardDisk -VM $vm |

            Select @{N='Cluster';E={$cluster.Name}},

                @{N='ResourcePool';E={$rp.Name}},

                @{N='VM';E={$vm.Name}},

                @{N='Tools Status';E={$vm.ExtensionData.Guest.ToolsStatus}},

                @{N='HD';E={$_.Name}},

                @{N='Datastore';E={($_.Filename.Split(']')[0]).TrimStart('[')}},

                @{N='Filename';E={($_.Filename.Split(' ')[1]).Split('/')[0]}},

                @{N='VMDK Path';E={$_.Filename}},

                @{N='Format';E={$_.StorageFormat}},

                @{N='Type';E={$_.DiskType}},

                @{N='CapacityGB';E={$_.CapacityGB}}

        }

   $report | Export-Csv C:\temp\report.csv -NoTypeInformation -UseCulture

}}

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
cjscol
Expert
Expert
Jump to solution

You are missing ExtensionData from the OS objects, i.e.

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

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

I think what you are referring to by the "auto fill" is that the application you are using to open the csv file, e.g. MS Excel, does not automatically show the whole contents of each field as the column widths are too narrow. A csv file is a text file with each value separated by a comma, try opening the file in a text editor such as notepad to see.

Calvin Scoltock VCP 2.5, 3.5, 4, 5 & 6 VCAP5-DCD VCAP5-DCA http://pelicanohintsandtips.wordpress.com/blog LinkedIn: https://www.linkedin.com/in/cscoltock

View solution in original post

0 Kudos
5 Replies
Nomi_epc
Enthusiast
Enthusiast
Jump to solution

Somehow, I managed to create the below script but doesn't contains any OS data as both Guest field are empty. Please help me out on this. I think i need to add get-view function in it ?  Moreover, Can i create a CSV file with auto fill field like whenever i need to see csv file i have to expand each and every column. IS there nay function in which i will get a auto fill csv file ?

$report = @()

foreach($cluster in Get-Cluster){

    foreach($rp in Get-ResourcePool -Location $cluster){

        foreach($vm in (Get-VM -Location $rp)){

            $report += Get-HardDisk -VM $vm |

            Select @{N='Cluster';E={$cluster.Name}},

                @{N='ResourcePool';E={$rp.Name}},

                @{N='VM';E={$vm.Name}},

                @{N='HD';E={$_.Name}},

                @{N='Datastore';E={($_.Filename.Split(']')[0]).TrimStart('[')}},

                @{N='Filename';E={($_.Filename.Split(' ')[1]).Split('/')[0]}},

                @{N='VMDK Path';E={$_.Filename}},

                @{N='Format';E={$_.StorageFormat}},

                @{N='Type';E={$_.DiskType}},

                @{N='VM Tools Status';E={$vm.ExtensionData.Guest.ToolsStatus}},

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

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

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

                 }

    $report | Export-Csv C:\temp\report.csv -NoTypeInformation -UseCulture

   }

}

0 Kudos
cjscol
Expert
Expert
Jump to solution

You are missing ExtensionData from the OS objects, i.e.

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

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

I think what you are referring to by the "auto fill" is that the application you are using to open the csv file, e.g. MS Excel, does not automatically show the whole contents of each field as the column widths are too narrow. A csv file is a text file with each value separated by a comma, try opening the file in a text editor such as notepad to see.

Calvin Scoltock VCP 2.5, 3.5, 4, 5 & 6 VCAP5-DCD VCAP5-DCA http://pelicanohintsandtips.wordpress.com/blog LinkedIn: https://www.linkedin.com/in/cscoltock
0 Kudos
CRad14
Hot Shot
Hot Shot
Jump to solution

Alternatively $vm.guest.osfullname would work instead of using extensiondata, but yeah, they both work Smiley Happy

Conrad www.vnoob.com | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! 🙂
0 Kudos
Nomi_epc
Enthusiast
Enthusiast
Jump to solution

Many thanks cjscol‌ Really appreciated your help Smiley Happy

Can i include more information about OS ? is there nay other information or function which i can use about OS in this script ? like server 2012 Standard version or Enterprise Version etc ? 

0 Kudos
Nomi_epc
Enthusiast
Enthusiast
Jump to solution

thanks Smiley Happy i will use this alternatively.

0 Kudos