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
}}
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.
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
}
}
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.
Alternatively $vm.guest.osfullname would work instead of using extensiondata, but yeah, they both work
Many thanks cjscol Really appreciated your help
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 ?
thanks i will use this alternatively.