Datasheet

SET UP YOUR VCENTER SERVER FOLDER STRUCTURE 13
Install, Con gure, and
Manage the vSphere
Environment
PART I
get-folder | Get-Folderpath
$Report | foreach {
if ($type -eq “vm”) {
$_.Path = ($_.Path).Replace($dc + “\”,”$type\”)
}
}
$report | Export-Csv $filename -NoTypeInformation
}
}
Function Export-VMLocation {
<#
.SYNOPSIS
Creates a csv file with the folder location of each VM.
.DESCRIPTION
The function will export VM locations from vCenter Server
and add them to a CSV file.
.NOTES
Source: Automating vSphere Administration
Authors: Luc Dekens, Arnim van Lieshout, Jonathan Medd,
Alan Renouf, Glenn Sizemore
.PARAMETER DC
The Datacenter where the folders reside
.PARAMETER Filename
The path of the CSV file to use when exporting
.EXAMPLE 1
PS> Export-VMLocation -DC “DC01” `
-Filename “C:\VMLocations.csv”
#>
param(
[String]$DC,
[String]$Filename
)
Process {
$report = @()
$report = get-datacenter $dc | get-vm | Get-Folderpath
$report | Export-Csv $filename -NoTypeInformation
890790c01.indd 13890790c01.indd 13 3/3/11 10:22:15 AM3/3/11 10:22:15 AM