Hi, I'm currently working on Exporting Elements out of our vCenter Environments into a CSV File:
such as vCenter /DataCenter/ Cluster / DataStore / vDS & Standard Switching / Templates (If Template Not Found Export Null or None)
vCenter | Cluster | DataStore | Network | Templates
test1 | Test1_cluster_a | San1 | vDS_test | win_12
test1 | Test1_cluster_a | San2 | VDS_test | win_12
test2 | Test2_cluster_b | San3 | VDS_test | win_12
test2 | Test2_cluster_c | San3 | VDS_test | Null
Not sure if this is the best approach to doing such: At the moment:
#vCenter Variables
$user = ''
$pswd = ''
$vCenter_Servers = " ", " " , " "
$report = foreach($vCenter in $vCenter_Servers) {
Connect-VIServer -Server $vCenter -User $user -Password $pswd
foreach($DataCenter in Get-Datacenter){
foreach($cluster in Get-Cluster){
foreach($datastore in Get-Datastore){
foreach($switch in Get-VDSwitch){
foreach($Template in Get-Template){
$obj = New-Object PSObject -Property @{
Vcenter = $vCenter.Name
Cluster = $cluster.Name
DataStore = $datastore.name
Switch = $Switch.Name
Template = $vm.Template
}
$obj
}
}
}
}
}
}
$report |
Select Vcenter,Cluster,DataStore,Template |
Export-Csv -Path C:\Scripts\Report5.csv -NoTypeInformation -UseCulture