Hi! That's what i think you want. Maybe exploring the Get-datastore cmdlet you can have all information you're looking for. =)
#loading powercli environment
if(!(get-pssnapin|where{$_.name-eq"vmware.vimautomation.core"})) {
try{
add-pssnapinVMware.VimAutomation.Core
}catch{
$ErrorMessage=$_.Exception.Message
outputThis"$ErrorMessage"
}
}
#change the parameter Server to your vCenter
$myvc=connect-viserver-Server"yourServer"-wa0
#you can get the datastores by the Hosts in your clusters
$myclusters=Get-Cluster-Server$myvc
$info2export=@()
foreach($clusterin$myclusters){
$datastoresPerCluster=$cluster|Get-VMhost|Get-Datastore
foreach($datastorein$datastoresPerCluster){
$partialInfo=""|selectClusterName,DatastoreName,CapacitySpaceUsed,FreeSpace
$partialInfo.ClusterName=$cluster.Name
$partialInfo.DatastoreName=$datastore.Name
#$partialInfo.ProvisionedSpace = ?
$partialInfo.CapacitySpaceUsed=$datastore.CapacityGB
$partialInfo.FreeSpace=$datastore.FreeSpaceGB
$info2export+=$partialInfo
}
}
#Export to csv in the path you want
$path="c:\temp\datastoreList.csv"
$info2export|Export-Csv-Path$path-NoTypeInformation-UseCulture
↧
Article 81
↧