Datasheet

SET UP YOUR VCENTER SERVER FOLDER STRUCTURE 11
Install, Con gure, and
Manage the vSphere
Environment
PART I
Exporting a Folder Structure
Both yellow and blue folder views can be exported to a CSV  le. You will  nd this
technique useful when you are rebuilding your vCenter Server from scratch or cre-
ating a DR replica of the current virtual infrastructure.
e script in Listing 1.3 can be used to export either a blue or a yellow folder structure
to a CSV. It can also be used to export the location of the current VMs, ensuring a rep-
licated location when you reimport the structure.
LISTING 1.3
Exporting a vCenter structure to a CSV fi le
Filter Get-FolderPath {
<#
.SYNOPSIS
Colates the full folder path
.DESCRIPTION
The function will find the full folder path returning a
name and path
.NOTES
Source: Automating vSphere Administration
Authors: Luc Dekens, Arnim van Lieshout, Jonathan Medd,
Alan Renouf, Glenn Sizemore
#>
$_ | Get-View | % {
$row = “” | select Name, Path
$row.Name = $_.Name
$current = Get-View $_.Parent
$path = $_.Name
do {
$parent = $current
if($parent.Name -ne “vm”){
$path = $parent.Name + “\” + $path
}
$current = Get-View $current.Parent
} while ($current.Parent -ne $null)
$row.Path = $path
$row
}
}
890790c01.indd 11890790c01.indd 11 3/3/11 10:22:15 AM3/3/11 10:22:15 AM