Example: a Windows or PowerShell 7 monitoring host contacts two fictional clusters. daily-health.ps1 exports one CSV row per cluster with node, aggregate, volume and SnapMirror status. inventory-report.ps1 exports each volume with SVM, state, size and usage. Both load inventory.csv through Import-Csv and follow ONTAP REST next-page links.
Commands and screens can differ by release and platform. Replace example names and documentation IP addresses. Check prerequisites, impact, current health and rollback with your change owner.
1. Prepare PowerShell 7, account and trust
- Install PowerShell 7 and download daily-health.ps1, inventory-report.ps1 and inventory.csv into one directory. Set the CSV Address column to the cluster management IPs. For each cluster, allow HTTPS management access from this host, grant a dedicated account read access to the four REST resources, and verify your ONTAP version supports the requested fields.
- Install the ONTAP issuing CA certificate into the trusted certificate store on the monitoring host. If certificates identify DNS names rather than IPs, replace addresses in inventory with those DNS names and ensure their certificates match. The scripts do not bypass TLS certificate checking.
- Run Get-Credential interactively; this example shares one account/password across entries. If clusters need different identities, separate inventory runs or adapt credential lookup by cluster. Keep CSV inventories free of passwords.
Cluster,Address
lab-a,192.0.2.10
lab-b,192.0.2.11
$credential = Get-Credential
./daily-health.ps1 -InventoryPath ./inventory.csv -Credential $credential -OutDir ./reports -CapacityThreshold 85The prompt requests credentials; reports/health-UTC.csv contains one row for each cluster and a Status of OK, WARN or ERROR.
2. Understand every check
- The script requests /api/cluster/nodes and warns when a node state differs from up, or no nodes are returned. It checks aggregate block_storage used/size and volume space used/size against the supplied percentage threshold. It warns on volumes whose state differs from online and relationships with healthy=false.
- Status ERROR means one of the REST calls or authentication failed for that cluster; Details contains the exception. Status WARN lists threshold or state findings. Status OK means only these four API checks found no exception. It does not assert HA readiness, EMS status, all SnapMirror RPOs or application health.
- The client requests 1000 records per page and follows _links.next.href while checking the host and /api/ prefix. Confirm that your monitoring account can read all pages. Review limits for your workload and add checks for lag and health alerts before treating the CSV as a complete operational verdict.
Import-Csv ./reports/health-20260101T070000Z.csv | Format-Table Cluster,Status,Details -Wrap
./daily-health.ps1 -InventoryPath ./inventory.csv -Credential $credential -CapacityThreshold 80A deliberately offline test volume or low threshold produces WARN and a nonzero process exit.
3. Export a detailed volume inventory
- The second script reads the same inventory.csv with Import-Csv and calls /api/storage/volumes for each cluster. For every returned volume it writes Cluster, SVM, Volume, State, SizeGiB and UsedGiB. Check the output against System Manager and handle the CSV as operational metadata.
- Run the example below from PowerShell 7. If one cluster fails, this inventory script stops rather than writing a deceptively complete list. It follows all REST pages and refuses a pagination URL that changes the host.
$credential = Get-Credential
./inventory-report.ps1 -InventoryPath ./inventory.csv -Credential $credential -OutFile ./volume-inventory.csv
Import-Csv ./volume-inventory.csv | Select-Object -First 5Volume rows include both clusters, and record counts agree with a filtered System Manager view.
4. Schedule safely and diagnose failures
- For unattended runs, create a restricted scheduled-task account and retrieve a secret from an approved Windows secret store or managed identity workflow inside a small wrapper that builds PSCredential. Get-Credential is interactive and cannot serve an unattended task. Avoid plaintext passwords, embedded script credentials, and disabling certificate checks.
- Create a Windows Task Scheduler daily trigger and action: pwsh.exe -NoProfile -File C:\Ops\run-health.ps1, where the wrapper obtains a credential and invokes daily-health.ps1. Grant the account write access to the report directory. Capture exit code and alert on WARN/ERROR or missing CSV.
- For HTTP 401/403 check account permissions and REST role mapping; for certificate errors check CA trust and hostname; for timeouts check the cluster-management LIF and firewall; for unexpected empty output check API field permissions and inventory header spelling.
A scheduled run creates a fresh CSV for all clusters, and task monitoring detects nonzero exits.