I am trying to document the folder structure inside virtual center. Is there a way to get at this information through powershell? I got as far as:
$test = get-vm somevmname
$test.extensiondata.parent
Type Value
---- -----
Folder group-v1926
Is there anyway to map group-v1926 back to it's description that is displayed in VC? Also could this be done recursively to find your way back to the top of the structure if you have nested folders?
The Extensiondata.Parent property is a MoRef (Managed Object Reference), which is in fact a pointer to the actual object.
But in PowerCLI 4.x you don't need to use the Extensiondata to get the folder paths anymore.
You can do something like this
$report = @()
foreach($vm in Get-VM){
$parent = $vm.Folder
$path = $vm.Name
while ($parent){
$path = $parent.Name + "/" + $path
$parent = $parent.Parent
}
$row = "" | Select VM,Path
$row.VM = $vm.Name
$row.Path = $path
$report += $row
}
$report
This will give you the name of the VM and blue folder path.
If you need to have the yellow folder path, you would need a different script.
Let me know if that is needed as well ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The Extensiondata.Parent property is a MoRef (Managed Object Reference), which is in fact a pointer to the actual object.
But in PowerCLI 4.x you don't need to use the Extensiondata to get the folder paths anymore.
You can do something like this
$report = @()
foreach($vm in Get-VM){
$parent = $vm.Folder
$path = $vm.Name
while ($parent){
$path = $parent.Name + "/" + $path
$parent = $parent.Parent
}
$row = "" | Select VM,Path
$row.VM = $vm.Name
$row.Path = $path
$report += $row
}
$report
This will give you the name of the VM and blue folder path.
If you need to have the yellow folder path, you would need a different script.
Let me know if that is needed as well ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks! Hope your new book is selling out. My copy is on the way from amazon.
Thanks, I hope you'll like it
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference