Get-Statistic
VMware: Retrieves statistical information from a vCenter Server system
#Requires -Version 5.1
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential,
[switch]$Common,
[switch]$CPU,
[switch]$Memory,
[switch]$Disk,
[switch]$Network,
[ValidateRange(1, 100)]
[int]$MaxResult = 20
)
Process {
try {
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$result = Get-Stat -Server $vmServer -Common:$Common -Memory:$Memory -Cpu:$CPU -Disk:$Disk -Network:$Network -ErrorAction Stop | Select-Object -First $MaxResult
if ($null -ne $result) { foreach ($item in $result) { $item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force } }
}
catch { throw }
finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}IP address or DNS name of the vSphere server
PSCredential object for authenticating with the server
Off
Collects common CPU, disk, memory, and network statistics
Off
Collects common CPU statistics
Off
Collects common memory statistics
Off
Collects common disk statistics
Off
Collects common network statistics
Maximum number of results to retrieve (1-100)