$resoucegname = $ret[0].Name $body = '{ "resources": [ "*" ], "options": "IncludeParameterDefaultValue,IncludeComments" }' $requesturi = "https://management.azure.com/subscriptions/$subscriptionid/resourcegroups/$resoucegname/exportTemplate?api-version=2021-04-01" $ret = (Invoke-WebRequest -Uri $requesturi -Headers $headers -Method Post -Body $body) $ret $requesturi = $ret.Headers.Location