This commit is contained in:
Zack Meier
2026-04-15 15:45:50 -05:00
commit 1d304511b8
613 changed files with 140998 additions and 0 deletions
@@ -0,0 +1,58 @@
<#
.SYNOPSIS
Usage report for VMware datastores.
.DESCRIPTION
Usage report for VMware datastores.
.NOTES
Requires VMware PowerCLI module.
Requires connection to vCenter.
.EXAMPLE
Get-ITDVMwareDatastoreReport
Retrieves a report of all datastores in the vCenter.
.EXAMPLE
Get-ITDVMwareDatastoreReport -Name "*78*"
Retrieves a report of all datastores in the vCenter that match the name pattern "*78*".
.PARAMETER Name
The name of the datastore to retrieve. If not specified, all datastores will be returned.
Supports wildcards.
#>
function Get-ITDVMwareDatastoreReport {
[CmdletBinding()]
param (
[string]
$Name
)
begin {
}
process {
if ($PSBoundParameters.ContainsKey('Name')) {
$AllDatastores = Get-Datastore -Name $Name
}
else {
$AllDatastores = Get-Datastore
}
foreach ($Datastore in $AllDatastores) {
$FreeSpaceGB = $Datastore.FreeSpaceGB
$CapacityGB = $Datastore.CapacityGB
$UsedSpaceGB = $CapacityGB - $FreeSpaceGB
$obj = [PSCustomObject]@{
Name = $Datastore.Name;
Datacenter = $Datastore.Datacenter.Name
FreeSpaceGB = $FreeSpaceGB;
UsedSpaceGB = ($CapacityGB - $FreeSpaceGB);
CapacityGB = $CapacityGB;
FreePercent = [math]::round($Datastore.FreeSpaceGB / $Datastore.CapacityGB * 100, 2);
}
#$null = $Result.Add($obj)
Write-Output $obj
}
}
end {
}
}