Open jeffwmiles opened 4 years ago
This is the Debug output from PowerShell 5.1
Name Value
---- -----
PSVersion 5.1.18362.628
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.628
CLRVersion 4.0.30319.42000
ModuleType Version Name
---------- ------- ----
Script 1.7.4 Az.Accounts
Script 1.3.6 Az.Automation
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/4ceb974a-REDACTED/resourceGroups/rgname/providers/M
icrosoft.Automation/automationAccounts/automationAccount/jobSchedules/23e424e0-fe66-450f-b7ff-589aa8fb82be?api-version=2015
-10-31
Headers:
x-ms-client-request-id : 3878d38e-19d1-4f34-a14c-
accept-language : en-US
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Pragma : no-cache
x-ms-request-id : 9e4c3729-569f-493f-
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 11995
x-ms-correlation-request-id : f3f455fe-dfcf-48c3-
x-ms-routing-request-id : NORTHCENTRALUS:20200406T170738Z:f3f455fe-dfcf-48c3-96de-6f9cd27043ab
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Mon, 06 Apr 2020 17:07:37 GMT
Server : Microsoft-IIS/10.0
X-AspNet-Version : 4.0.30319
X-Powered-By : ASP.NET
Body:
{
"id":
"/subscriptions/4ceb974a-REDACTED/resourceGroups/rgname/providers/Microsoft.Automation/automat
ionAccounts/automationAccount/jobSchedules/23e424e0-fe66-450f-b7ff-589aa8fb82be",
"type": "Microsoft.Automation/AutomationAccounts/JobSchedules",
"properties": {
"jobScheduleId": "23e424e0-fe66-450f-b7ff-589aa8fb82be",
"runbook": {
"name": "hfx-nsg-interface-update"
},
"schedule": {
"name": "6Hours-automationjobruntimedata"
},
"runOn": null,
"parameters": {
"SubscriptionId": "\"047f8a8b-REDACTED\"",
"RuleName": "\"any_automationjobruntimedata_443\"",
"endpointfqdn": "\"eus2-jobruntimedata-prod-su1.azure-automation.net\"",
"nsggroup": "[\r\n \"db-nsg\",\r\n \"prod-extweb-nsg\",\r\n \"prod-nsg\",\r\n
\"test-nsg\",\r\n \"mgmt-nsg\"\r\n]",
"ports": "[\r\n 443,\r\n 80\r\n]"
}
}
}
DEBUG: AzureQoSEvent: CommandName - Get-AzAutomationScheduledRunbook; IsSuccess - True; Duration - 00:00:01.0605458;
Exception - ;
DEBUG: Finish sending metric.
DEBUG: 11:08:18 AM - GetAzureAutomationScheduledRunbook end processing.
DEBUG: 11:08:18 AM - GetAzureAutomationScheduledRunbook end processing.
This time the $setparams output contains the parameters:
I've been trying to dig a little deeper on this with my limited knowledge of debugging PowerShell. If I hit the API directly with the URI given in the debug output, I get the exact same response between PowerShell 5.1 and 7.
#https://gallery.technet.microsoft.com/scriptcenter/Easily-obtain-AccessToken-3ba6e593
. .\Get-AzCachedAccessToken.ps1
$BearerToken = ('Bearer {0}' -f (Get-AzCachedAccessToken))
$RequestHeader = @{
"Content-Type" = "application/json";
"Authorization" = "$BearerToken"
}
$URI = "https://management.azure.com/subscriptions/4ceb974a-REDACTED/resourceGroups/rgname/providers/Microsoft.Automation/automationAccounts/automationaccount/jobSchedules/1c5af1da-1c7b-4583-9879-a0b5676fd55d?api-version=2015-10-31"
$Response = Invoke-RestMethod -Uri $URI -Method GET -header $RequestHeader
I searched through the PS7 release notes for references to JSON handling, and came across this item: #3424. Perhaps this is related - I tried to round-trip the conversion of my $response, and got different results.
I can't understand the link in the Az.Automation module code between the Get-AzAutomationAccountScheduledRunbook and JSON handling to return the hashtable yet, so I'm stuck going deeper at this point.
@jeffwmiles, thanks for reporting. We will look into it
Hi @jeffwmiles , we have confirmed that this is caused by the issue of converting the strings with escape chars into json object. We will fix it in the future.
This issue doesn't appear to be resolved by the fix on #12283 - when I repeat the test (with Az.Automation module 1.4.0 on PowerShell Core 7.1 now), I do see the debug output is modified:
However the output is still malformed (although not actually null):
Similar to the related issue #12702 , the type is returned as a Json.Linq.Jvalue:
And converting this back to JSON returns and empty array:
Description
When using Get-AzAutomationScheduledRunbook, for a JobSchedule that contains an array in a parameter, the output of the Parameter property is missing for that specific parameter.
Steps to reproduce
Result is that in the Portal, the parameter is created as an array properly:![portal](https://user-images.githubusercontent.com/40004712/78583851-9b553680-77f4-11ea-96b8-f836e4e31f13.png)
However, when looking at $setparams, the values for ports and nsggroup are empty:![setparams](https://user-images.githubusercontent.com/40004712/78585626-65fe1800-77f7-11ea-831d-934a2b8d1eb1.png)
See Debug output below, where the actual REST API call returns JSON containing the parameters, but with additional /r/n line breaks added.
It appears that the conversion of the REST JSON body into a PowerShell Hashtable in Powershell 7 isn't functioning, where it does in PowerShell 5.1 or 6.
Environment data
This only appears to occur on PowerShell 7; not 6 or 5.1
Module versions
Debug output
Error output
No errors encountered