BrownField/Auto-assessment/scripts/Get-DHCP-Azure.ps1 (29 lines of code) (raw):
function Get-DHCP-Azure {
param(
[SecureString]$token,
[PSCustomObject]$sddc
)
try {
# Get AVS SDDC details
$sddcDetails = Get-AVS-SDDC-Details -sddc $sddc
# Define the API URL
$apiUrl = [string]::Format(
"https://management.azure.com/subscriptions/{0}/" +
"resourceGroups/{1}/providers/Microsoft.AVS/privateClouds/{2}/" +
"workloadNetworks/default/dhcpConfigurations?api-version=2023-09-01",
$sddcDetails.subscriptionId,
$sddcDetails.resourceGroupName,
$sddcDetails.sddcName
)
# Make the request
$response = Invoke-APIRequest `
-method "Get" `
-url $apiUrl `
-token $token
# return the response
return $response
}
catch {
Write-Error "Azure DHCP Test failed: $_"
}
}