BrownField/Auto-assessment/scripts/Test-HCX-Addon.ps1 (43 lines of code) (raw):
function Test-HCX-Addon {
param (
[SecureString]$token,
[PSCustomObject]$sddc
)
try {
# Get AVS SDDC details
$sddcDetails = Get-AVS-SDDC-Details -sddc $sddc
# Define API Endpoint
$apiUrl = [string]::Format(
"https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/" +
"Microsoft.AVS/privateClouds/{2}/addons/hcx?api-version=2023-09-01",
$sddcDetails.subscriptionId,
$sddcDetails.resourceGroupName,
$sddcDetails.sddcName
)
# Make the request
$response = Invoke-APIRequest `
-method "Get" `
-url $apiUrl `
-token $token
# Process the response
if ($response) {
if ($response.properties.provisioningState -ne "Succeeded") {
$recommendationType = "HCXNotProvisioned"
}
else {
return "HCXProvisioned"
}
} else {
$recommendationType = "HCXNotProvisioned"
}
# Add the recommendation
if (![string]::IsNullOrEmpty($recommendationType)) {
$Global:recommendations += Get-Recommendation -type $recommendationType `
-sddcName $sddc.name
}
return $recommendationType
}
catch {
Write-Error "HCX Addon Test failed: $_"
}
}