forked from vxav/Scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-Datastore2.ps1
26 lines (19 loc) · 955 Bytes
/
Get-Datastore2.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Function Get-Datastore2 {
param(
[parameter(position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyname=$True)]
[VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore[]]
$Datastore
)
Process{
$Datastore | ForEach-Object {
[pscustomobject]@{
Name = $_.name
CapacityGB = [Math]::Round(($_.extensiondata.summary.capacity / 1GB),2)
FreeSpaceGB = [Math]::Round(($_.extensiondata.summary.FreeSpace / 1GB),2)
UsedSpaceGB = [Math]::Round((($_.extensiondata.summary.capacity / 1GB) - ($_.extensiondata.summary.FreeSpace / 1GB)),2)
ProvisionedGB = [Math]::Round((($_.extensiondata.summary.capacity / 1GB) - ($_.extensiondata.summary.FreeSpace / 1GB) + ($_.extensiondata.summary.Uncommitted / 1GB)),2)
NbRunningVMs = ($_ | Get-VM | where powerstate -eq Poweredon).count
}
}
}
}