First of all, thank you for this tutorial!
Just a couple remarks that I've noticed:
1) I believe it should be [7] instead of [8]:
$aksClusterName = $($aksClusterResourceId -split '/')[7]
Since aksclusterResourceId is something like this:
subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}
2) Maybe it makes sense to refactor the second try-catch and move this code into 'else' sections:
#Performning the operation
$postResponse = Invoke-WebRequest -UseBasicParsing -Method Post -Headers $headers_Auth -Uri $postRestUri
$StatusCode = $postResponse.StatusCode
Otherwise, `Invoke-WebRequest` will be called when it should not (for example, stop operation for the stopped cluster or start operation for the running cluster).