75 lines
2.6 KiB
PowerShell
75 lines
2.6 KiB
PowerShell
<#
|
|
VM level:
|
|
VM Name
|
|
Storage provisioned per disk
|
|
Storage used per disk
|
|
Free capacity per disk
|
|
Disk Mode ( dependent persistent vs independent persistent )
|
|
Disk Type ( Thick, thin, lazy, eager, etc... )
|
|
Datastore
|
|
Replication Technology, if applicable
|
|
Datacenter
|
|
#>
|
|
|
|
$VMStorageList = [System.Collections.ArrayList]@()
|
|
$AllVMs = Get-VM | Where-Object { $_.ExtensionData.summary.config.ManagedBy.Type -ne "placeholderVm" }
|
|
ForEach($VM in $AllVMs){
|
|
$VmObj = [PSCustomObject]@{
|
|
VMName = $VM.Name;
|
|
UsedSpaceGB = $VM.UsedSpaceGB;
|
|
ProvisionedSpaceGB = $VM.ProvisionedSpaceGB;
|
|
Datastores = ($VM | Get-Datastore).Name
|
|
DatastoreCluster = ($VM | Get-DatastoreCluster).Name
|
|
Replication = switch ( ($VM | Get-TagAssignment -Category 'VR RPO').Tag.Name ){
|
|
{$_ -like "*ABR*"} {"ABR"}
|
|
{$_ -like "*:*"} {"VR"}
|
|
Default {$false}
|
|
}
|
|
Datacenter = ($VM | Get-Datacenter).Name
|
|
Disks = $VM | Get-HardDisk | Select-Object Name,CapacityGB,@{n='StorageFormat';e={$_.StorageFormat.ToString()}},@{n='Persistence';e={$_.Persistence.ToString()}}
|
|
}
|
|
$null = $VMStorageList.Add($VmObj)
|
|
}
|
|
|
|
$VMStorageList | ConvertTo-Json -Depth 5 | Out-File "C:\temp\VMs.json"
|
|
|
|
|
|
|
|
|
|
<#
|
|
Datastore:
|
|
Name
|
|
Capacity provisioned
|
|
Capacity used
|
|
Free capacity
|
|
Associated SAN device backing ( LUN Name )
|
|
Space Reclamation rate ( MB/s )
|
|
Datacenter
|
|
#>
|
|
|
|
$AllDatastores = Get-Datastore
|
|
$DatastoreList = [System.Collections.ArrayList]@()
|
|
ForEach($Datastore in $AllDatastores){
|
|
Write-Verbose -Message ("Start " + $Datastore.Name) -Verbose
|
|
#$Metadata = ($Datastore | Get-ScsiLun | Select-Object -First 1)
|
|
|
|
If ( $Datastore.ExtensionData.info.vmfs.UnmapBandwidthSpec.FixedValue){
|
|
# if reclamation rate is enabled at fixed rate, get that rate
|
|
$ReclamationRate = ("Enabled at fixed rate: " + $Datastore.ExtensionData.info.vmfs.UnmapBandwidthSpec.FixedValue + " MB/s")
|
|
} Else {
|
|
$ReclamationRate = "UnmapBandwidthSpec is null. Enabled at Low priority: Deleted or unmapped blocks are reclaimed on the LUN at low priority"
|
|
}
|
|
|
|
$DatastoreObj = [PSCustomObject]@{
|
|
Name = $Datastore.Name;
|
|
CapacityGB = $Datastore.CapacityGB;
|
|
UsedSpaceGB = ($Datastore.CapacityGB - $Datastore.FreeSpaceGB);
|
|
FreeSpaceGB = $Datastore.FreeSpaceGB;
|
|
CanonicalName = ($Datastore | Get-ScsiLun | Select-Object -First 1).CanonicalName;
|
|
SpaceReclamationRate = $ReclamationRate;
|
|
Datacenter = ($VMHostToUse | Get-Datacenter).Name
|
|
}
|
|
$null = $DatastoreList.Add($DatastoreObj)
|
|
}
|
|
|
|
$DatastoreList | ConvertTo-Json -Depth 5 | Out-File "C:\temp\Datastores.json" |