First time posting...
PRISM Central Version 2024.2
PowerShell 7.4.6
1. Was able to load Nutanix.Prism.PS.Cmds and connect to a Cluster (via Uuid), but gave up on trying to extract MEMORY statistics. (Get-ClusterStats as well as Get-VMStats are not recognized.)
2. Now trying REST method, which is a first also. The following code did display the Clusters but showed 0 for all MEMORY values. Anyone see a better way to get these values?
$PrismCentralIP = "x.x.x.x"
$Username = "user"
$Password = "password"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${Username}:${Password}"))
$headers = @{
Authorization = "Basic $base64AuthInfo"
Accept = "application/json"
}
$response = Invoke-RestMethod -Uri "https://x.x.x.x:9440/api/nutanix/v3/clusters/list" -Method Post -Headers $headers -Body "{}" -ContentType "application/json" -SkipCertificateCheck
foreach ($cluster in $response.entities) {
$clusterName = $cluster.spec.name
$totalMemory = $cluster.status.resources.memory_capacity_in_bytes / 1MB
$usedMemory = $cluster.status.resources.memory_usage_in_bytes / 1MB
$freeMemory = $totalMemory - $usedMemory
Write-Output "Cluster Name: $clusterName"
Write-Output "Total Memory: $totalMemory MB"
Write-Output "Used Memory: $usedMemory MB"
Write-Output "Free Memory: $freeMemory MB"
}
Result:
