Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MichaelRyom/4a5a95b26d1244221793214c827ccdad to your computer and use it in GitHub Desktop.
Save MichaelRyom/4a5a95b26d1244221793214c827ccdad to your computer and use it in GitHub Desktop.
#Variables
$username = "admin"
$password = "Password"
$vRopsFQDN = "vRops"
#vRops SSL certificate trust
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#Convert username and password till securestring
$secPw = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object PSCredential -ArgumentList $username,$secPw
#Call vRops API
$alert = Invoke-RestMethod -Method Get -Uri "https://$vRopsFQDN/suite-api/api/alerts/?pageSize=5000" -Credential $cred
$DSClusterAlert = @()
Foreach($AlertID in (($alert.alerts.alert | where {$_.status -match "active" -and $_.alertDefinitionName -match "Datastore is running out of disk space"}).resourceId)){
$Details = "" | Select Name
$Details.Name = ((Invoke-RestMethod -Method Get -Uri "https://$vRopsFQDN/suite-api/api/resources/$AlertID/relationships/parents" -Credential $cred) | where {$_.'resource-relation'.resource.resourceKey.resourceKindKey -match "StoragePod"}).'resource-relation'.resource.resourceKey | where {$_.resourceKindKey -match "StoragePod"} | select Name
$DSClusterAlert += $Details
}
$DSClusterAlert.Name | Group-Object Name | select Name,Count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment