I have a PowerShell script where it will have to fetch the workspace details and run “ForEach” method.
while running the script I’m getting the below error that says.
“HandleException : The term ‘HandleException’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.”
Sample PowerShell script used:
Write-Output "Connecting Azure through AZ-DNA-SPN-P-GF-e2d5758f35d34798af4a SPN login"
Connect-AzAccount -ServicePrincipal -Tenant $tenantId -CertificateThumbprint $thumb -ApplicationId $appId
#Get all workspaces from given tenant
$workspace = GetWorkspaceDetails -UCApiBaseUrl $UCApiBaseUrl
Write-Output "Total workspaces found"
$workspace.Count
$workspace
$edpWorkspaces = $workspace |Where-Object { $_.workspace_name -Like "az-dna-*" }
Write-Output "EDP filtered workspaces are "
$edpWorkspaces.Count
try
{
$edpWorkspaces|ForEach-Object{
$workspace_item = $_
$workspace_item
Get External Locations
$externalLocations= GetExternalLocations -WorkspaceDeploymentName $($workspace.deployment_name)
$externalLocations
}
}
catch {
$ErrorMsg = HandleException -ErrorBody $_
Write-Error $ErrorMsg
exit 1
}