Le script suivant permet de lister la capacité et l’espace libre des datastores de chaque cluster de datastore du vCenter.
Connect-VIServer « nom-vCenter »
$excel = New-Object -ComObject Excel.Application
$excel.visible = $True
$excel = $excel.Workbooks.Add()
### Initialisation du tableau Excel ###
$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Cells.Item(1,1) = “Cluster”
$Sheet.Cells.Item(1,2) = “Datastore”
$Sheet.Cells.Item(1,3) = “Capacité”
$Sheet.Cells.Item(1,4) = “Espace Libre”
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 15
$WorkBook.Font.Bold = $True
$introw =2
$ClusterDatastores = Get-DatastoreCluster
foreach ($Cluster in $ClusterDatastores){
$MesDatastores = Get-DatastoreCluster $Cluster | Get-Datastore
foreach ($datastore in $MesDatastores){
#Remplissage du tableau
$Sheet.Cells.Item($intRow, 1) = $Cluster.Name
$Sheet.Cells.Item($intRow, 2) = $datastore.Name
$Sheet.Cells.Item($intRow, 3) = $datastore.CapacityGB
$Sheet.Cells.Item($intRow, 4) = $datastore.FreeSpaceGB
$intRow++
}
}
Leave A Comment