From 031edf0beaf5a38bde1935768963a7fb46a0e8d1 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Mon, 25 Jul 2022 18:19:12 +0530 Subject: [PATCH 01/15] Update AutomationPSClient.cs --- src/Automation/Automation/Common/AutomationPSClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/AutomationPSClient.cs b/src/Automation/Automation/Common/AutomationPSClient.cs index 069f3fed737f..7064b3c92f8a 100644 --- a/src/Automation/Automation/Common/AutomationPSClient.cs +++ b/src/Automation/Automation/Common/AutomationPSClient.cs @@ -2013,7 +2013,8 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript; - var outputFilePath = outputFolderFullPath + "\\" + runbookName + fileExtension; + char seperator = Path.DirectorySeparatorChar; + var outputFilePath = outputFolderFullPath + seperator + runbookName + fileExtension; // file exists and overwrite Not specified if (File.Exists(outputFilePath) && !overwriteExistingFile) From 666071c18e811e58bdfd97895fe084110bd70dae Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:35:57 +0530 Subject: [PATCH 02/15] Change summary limit --- src/Automation/Automation/Common/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/Constants.cs b/src/Automation/Automation/Common/Constants.cs index 62a434a49fd6..0c0cff21a3d6 100644 --- a/src/Automation/Automation/Common/Constants.cs +++ b/src/Automation/Automation/Common/Constants.cs @@ -63,7 +63,7 @@ public class AutomationAccountState public const int PsCommandValueDepth = 2; - public const int JobSummaryLength = 80; + public const int JobSummaryLength = 1000; public const int MaxWaitSeconds = 10800; From 4170c17cd85de1c35a01d5d8fda940c676f68f67 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:37:48 +0530 Subject: [PATCH 03/15] Update src/Automation/Automation/Common/AutomationPSClient.cs Co-authored-by: Beisi Zhou --- src/Automation/Automation/Common/AutomationPSClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/AutomationPSClient.cs b/src/Automation/Automation/Common/AutomationPSClient.cs index 7064b3c92f8a..6f25e44c1ca2 100644 --- a/src/Automation/Automation/Common/AutomationPSClient.cs +++ b/src/Automation/Automation/Common/AutomationPSClient.cs @@ -2014,7 +2014,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript; char seperator = Path.DirectorySeparatorChar; - var outputFilePath = outputFolderFullPath + seperator + runbookName + fileExtension; + var outputFilePath = Path.Join(outputFolderFullPath, runbookName + fileExtension); // file exists and overwrite Not specified if (File.Exists(outputFilePath) && !overwriteExistingFile) From 285c14f8bddde962201e594a0d25252df23ebf61 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 26 Jul 2022 16:56:32 +0530 Subject: [PATCH 04/15] Update JobStream.cs --- src/Automation/Automation/Model/JobStream.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Automation/Automation/Model/JobStream.cs b/src/Automation/Automation/Model/JobStream.cs index aa50069576f7..adae60929aff 100644 --- a/src/Automation/Automation/Model/JobStream.cs +++ b/src/Automation/Automation/Model/JobStream.cs @@ -53,9 +53,7 @@ public JobStream(AutomationManagement.Models.JobStream jobStream, string resourc if (!String.IsNullOrWhiteSpace(jobStream.Summary)) { - this.Summary = jobStream.Summary.Length > Constants.JobSummaryLength ? - jobStream.Summary.Substring(0, Constants.JobSummaryLength) + "..." : - jobStream.Summary; + this.Summary = jobStream.Summary; } } From 13dbf73973479756112d9755be672c0bb0eb9498 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 26 Jul 2022 16:57:02 +0530 Subject: [PATCH 05/15] Update Constants.cs --- src/Automation/Automation/Common/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/Constants.cs b/src/Automation/Automation/Common/Constants.cs index 0c0cff21a3d6..62a434a49fd6 100644 --- a/src/Automation/Automation/Common/Constants.cs +++ b/src/Automation/Automation/Common/Constants.cs @@ -63,7 +63,7 @@ public class AutomationAccountState public const int PsCommandValueDepth = 2; - public const int JobSummaryLength = 1000; + public const int JobSummaryLength = 80; public const int MaxWaitSeconds = 10800; From 0515cc15d68bce60e6326dc0cf3d75890e564230 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 26 Jul 2022 17:02:21 +0530 Subject: [PATCH 06/15] Update ChangeLog.md --- src/Automation/Automation/ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Automation/Automation/ChangeLog.md b/src/Automation/Automation/ChangeLog.md index 5b50d8c8a33b..91e61fdcd803 100644 --- a/src/Automation/Automation/ChangeLog.md +++ b/src/Automation/Automation/ChangeLog.md @@ -18,6 +18,8 @@ - Additional information about change #1 --> ## Upcoming Release +* Fixed bug: Export-AzAutomationRunbook no longer adds extra '\' to file names [#11101] +* Fixed bug: Get-AzAutomationDscCompilationJobOutput returns complete summaries [#12322] ## Version * * Added logic of returning error if insufficient user permissions are there for `GetAgentRegistrationInfo` From 74650784b0193c07681e02b9ebf921beecd22c65 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 26 Jul 2022 17:08:30 +0530 Subject: [PATCH 07/15] Update src/Automation/Automation/Common/AutomationPSClient.cs Co-authored-by: Beisi Zhou --- src/Automation/Automation/Common/AutomationPSClient.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Automation/Automation/Common/AutomationPSClient.cs b/src/Automation/Automation/Common/AutomationPSClient.cs index 6f25e44c1ca2..40e2154f546e 100644 --- a/src/Automation/Automation/Common/AutomationPSClient.cs +++ b/src/Automation/Automation/Common/AutomationPSClient.cs @@ -2013,7 +2013,6 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript; - char seperator = Path.DirectorySeparatorChar; var outputFilePath = Path.Join(outputFolderFullPath, runbookName + fileExtension); // file exists and overwrite Not specified From 31d23c249714d556eed3cd5a4cf5050ef7936e5d Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 2 Aug 2022 11:37:06 +0530 Subject: [PATCH 08/15] Update AutomationPSClient.cs --- src/Automation/Automation/Common/AutomationPSClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/AutomationPSClient.cs b/src/Automation/Automation/Common/AutomationPSClient.cs index 40e2154f546e..859202c779a7 100644 --- a/src/Automation/Automation/Common/AutomationPSClient.cs +++ b/src/Automation/Automation/Common/AutomationPSClient.cs @@ -2013,7 +2013,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript; - var outputFilePath = Path.Join(outputFolderFullPath, runbookName + fileExtension); + var outputFilePath = Path.Combine(outputFolderFullPath, runbookName + fileExtension); // file exists and overwrite Not specified if (File.Exists(outputFilePath) && !overwriteExistingFile) From 26316551c35562c2341cabafe5964d3e77a1e5cf Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:13:00 +0530 Subject: [PATCH 09/15] Update PowershellJsonConverter.cs --- .../Common/PowershellJsonConverter.cs | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Automation/Automation/Common/PowershellJsonConverter.cs b/src/Automation/Automation/Common/PowershellJsonConverter.cs index a43f02527c8a..3f1bad521951 100644 --- a/src/Automation/Automation/Common/PowershellJsonConverter.cs +++ b/src/Automation/Automation/Common/PowershellJsonConverter.cs @@ -51,10 +51,43 @@ public static PSObject Deserialize(string json) { return null; } - Hashtable parameters = new Hashtable(); + bool SuccessfulPSInvoke = false; + Collection result=null; parameters.Add(Constants.PsCommandParamInputObject, json); - var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); + using (var PS_GetVersion = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)) + { + PS_GetVersion.AddScript("(Get-Host).Version.Major"); + var PSVersion = Int32.Parse(PS_GetVersion.Invoke()[0].ToString()); + if(PSVersion>5) + { + try + { + result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); + SuccessfulPSInvoke = false; + } + catch (Exception) + { + + } + finally + { + if (!SuccessfulPSInvoke) + { + parameters.Remove(Constants.PsCommandParamInputObject); + if (!(json[0] == '"' && json[json.Length - 1] == '"') && !(json[0] == '\'' && json[json.Length - 1] == '\'')) + { + json = "'" + json + "'"; + } + parameters.Add(Constants.PsCommandParamInputObject, json); + } + } + } + } + if (!SuccessfulPSInvoke) + { + result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); + } if (result.Count != 1) { return null; From 59d9b1fedfcec7fd7ed9d590fd4cd5a4219f06eb Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:26:19 +0530 Subject: [PATCH 10/15] Update ChangeLog.md --- src/Automation/Automation/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Automation/Automation/ChangeLog.md b/src/Automation/Automation/ChangeLog.md index 91e61fdcd803..dc52b41a9176 100644 --- a/src/Automation/Automation/ChangeLog.md +++ b/src/Automation/Automation/ChangeLog.md @@ -20,6 +20,7 @@ ## Upcoming Release * Fixed bug: Export-AzAutomationRunbook no longer adds extra '\' to file names [#11101] * Fixed bug: Get-AzAutomationDscCompilationJobOutput returns complete summaries [#12322] +* Fixed bug: Get-AzAutomationJob fails for some jobIds ## Version * * Added logic of returning error if insufficient user permissions are there for `GetAgentRegistrationInfo` From 0973ab81a28463e5ce679cecd0b7c6c83720bdd4 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Mon, 8 Aug 2022 10:43:06 +0530 Subject: [PATCH 11/15] Update PowershellJsonConverter.cs --- .../Common/PowershellJsonConverter.cs | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/Automation/Automation/Common/PowershellJsonConverter.cs b/src/Automation/Automation/Common/PowershellJsonConverter.cs index 3f1bad521951..f06432a5db17 100644 --- a/src/Automation/Automation/Common/PowershellJsonConverter.cs +++ b/src/Automation/Automation/Common/PowershellJsonConverter.cs @@ -52,42 +52,20 @@ public static PSObject Deserialize(string json) return null; } Hashtable parameters = new Hashtable(); - bool SuccessfulPSInvoke = false; - Collection result=null; - parameters.Add(Constants.PsCommandParamInputObject, json); using (var PS_GetVersion = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)) { PS_GetVersion.AddScript("(Get-Host).Version.Major"); var PSVersion = Int32.Parse(PS_GetVersion.Invoke()[0].ToString()); if(PSVersion>5) { - try - { - result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); - SuccessfulPSInvoke = false; - } - catch (Exception) - { - - } - finally - { - if (!SuccessfulPSInvoke) + if (!(json[0] == '"' && json[json.Length - 1] == '"') && !(json[0] == '\'' && json[json.Length - 1] == '\'')) { - parameters.Remove(Constants.PsCommandParamInputObject); - if (!(json[0] == '"' && json[json.Length - 1] == '"') && !(json[0] == '\'' && json[json.Length - 1] == '\'')) - { - json = "'" + json + "'"; - } - parameters.Add(Constants.PsCommandParamInputObject, json); + json = "\"" + json + "\""; } - } } } - if (!SuccessfulPSInvoke) - { - result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); - } + parameters.Add(Constants.PsCommandParamInputObject, json); + var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); if (result.Count != 1) { return null; From 7373d0f9ea98cf87921087be53c851577ec4d2cb Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 9 Aug 2022 20:22:08 +0530 Subject: [PATCH 12/15] Update PowershellJsonConverter.cs --- .../Common/PowershellJsonConverter.cs | 55 +++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/Automation/Automation/Common/PowershellJsonConverter.cs b/src/Automation/Automation/Common/PowershellJsonConverter.cs index f06432a5db17..54efc8703972 100644 --- a/src/Automation/Automation/Common/PowershellJsonConverter.cs +++ b/src/Automation/Automation/Common/PowershellJsonConverter.cs @@ -44,35 +44,58 @@ public static string Serialize(object inputObject) return result[0].ToString(); } - - public static PSObject Deserialize(string json) + public static PSObject Deserialize(string json) { if (string.IsNullOrEmpty(json)) { return null; } + Hashtable parameters = new Hashtable(); - using (var PS_GetVersion = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)) + int PSVersion = 5; + Collection result=null; + bool JsonParseStatus = false; + PSVersion=AzurePSCmdlet.PowerShellVersion[0]-'0'; + parameters.Add(Constants.PsCommandParamInputObject, json); + if (PSVersion > 6) { - PS_GetVersion.AddScript("(Get-Host).Version.Major"); - var PSVersion = Int32.Parse(PS_GetVersion.Invoke()[0].ToString()); - if(PSVersion>5) + try + { + result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); + JsonParseStatus = true; + } + catch (Exception) + { + + } + if(!JsonParseStatus) + { + return json; + } + else { - if (!(json[0] == '"' && json[json.Length - 1] == '"') && !(json[0] == '\'' && json[json.Length - 1] == '\'')) - { - json = "\"" + json + "\""; - } + if (result.Count != 1) + { + return null; + } + return result[0]; } + } - parameters.Add(Constants.PsCommandParamInputObject, json); - var result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); - if (result.Count != 1) + else { - return null; + result = PowerShellJsonConverter.InvokeScript(Constants.PsCommandConvertFromJson, parameters); + + + if (result.Count != 1) + { + return null; + } + + //count == 1. return the first psobject + return result[0]; } - //count == 1. return the first psobject - return result[0]; } private static Collection InvokeScript(string scriptName, Hashtable parameters) From d520014abde07567e04723030b0ca2548e573c53 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Tue, 9 Aug 2022 20:36:36 +0530 Subject: [PATCH 13/15] Update PowershellJsonConverter.cs --- src/Automation/Automation/Common/PowershellJsonConverter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Automation/Automation/Common/PowershellJsonConverter.cs b/src/Automation/Automation/Common/PowershellJsonConverter.cs index 54efc8703972..e38eef5163b6 100644 --- a/src/Automation/Automation/Common/PowershellJsonConverter.cs +++ b/src/Automation/Automation/Common/PowershellJsonConverter.cs @@ -13,6 +13,7 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.Automation.Properties; +using Microsoft.WindowsAzure.Commands.Utilities.Common; using System; using System.Collections; using System.Collections.ObjectModel; From ade558b3b914ce9ba97ec9d2f6203d3396c054c0 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Wed, 10 Aug 2022 01:12:33 +0530 Subject: [PATCH 14/15] Update PowershellJsonConverter.cs --- .../Automation/Common/PowershellJsonConverter.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/PowershellJsonConverter.cs b/src/Automation/Automation/Common/PowershellJsonConverter.cs index e38eef5163b6..5d3141768ffa 100644 --- a/src/Automation/Automation/Common/PowershellJsonConverter.cs +++ b/src/Automation/Automation/Common/PowershellJsonConverter.cs @@ -56,8 +56,13 @@ public static PSObject Deserialize(string json) int PSVersion = 5; Collection result=null; bool JsonParseStatus = false; - PSVersion=AzurePSCmdlet.PowerShellVersion[0]-'0'; + // PSVersion=AzurePSCmdlet.PowerShellVersion[0]-'0'; parameters.Add(Constants.PsCommandParamInputObject, json); + using (var PS_GetVersion = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)) + { + PS_GetVersion.AddScript("(Get-Host).Version.Major"); + PSVersion = Int32.Parse(PS_GetVersion.Invoke()[0].ToString()); + } if (PSVersion > 6) { try From 4deffb4d66a2b3999192f328b7c5a776ef0abd50 Mon Sep 17 00:00:00 2001 From: Ab0907 <109592962+Ab0907@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:51:05 +0530 Subject: [PATCH 15/15] Update PowershellJsonConverter.cs --- .../Automation/Common/PowershellJsonConverter.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Automation/Automation/Common/PowershellJsonConverter.cs b/src/Automation/Automation/Common/PowershellJsonConverter.cs index 5d3141768ffa..3e9e71839ca3 100644 --- a/src/Automation/Automation/Common/PowershellJsonConverter.cs +++ b/src/Automation/Automation/Common/PowershellJsonConverter.cs @@ -56,13 +56,8 @@ public static PSObject Deserialize(string json) int PSVersion = 5; Collection result=null; bool JsonParseStatus = false; - // PSVersion=AzurePSCmdlet.PowerShellVersion[0]-'0'; + PSVersion = Int32.Parse(AzurePSCmdlet.PowerShellVersion[0].ToString()); parameters.Add(Constants.PsCommandParamInputObject, json); - using (var PS_GetVersion = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)) - { - PS_GetVersion.AddScript("(Get-Host).Version.Major"); - PSVersion = Int32.Parse(PS_GetVersion.Invoke()[0].ToString()); - } if (PSVersion > 6) { try