From 8a50733034f6956e6f13e079957ae068f15c8135 Mon Sep 17 00:00:00 2001 From: SimonZein <128088337+SimonZein@users.noreply.github.com> Date: Wed, 22 Mar 2023 03:27:43 +0100 Subject: [PATCH 1/7] Fix for Templates with nested Activities (#447) Added -Alias $alias to the recursive Update-SCSMPropertyCollection call --- smletsExchangeConnector.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index 3ef8ad05..bb8c3d5b 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -4611,7 +4611,7 @@ function Update-SCSMPropertyCollection { foreach ($obj in $Object.ObjectCollection) { - Update-SCSMPropertyCollection -Object $obj + Update-SCSMPropertyCollection -Object $obj -Alias $alias } } } From 798c09b7b2ded3137360b290604dc46a95d69e14 Mon Sep 17 00:00:00 2001 From: SimonZein <128088337+SimonZein@users.noreply.github.com> Date: Sat, 1 Apr 2023 17:30:40 +0200 Subject: [PATCH 2/7] Fix for Update-WorkItem with Comment length gt 4000 Whenever the update-workitem is called with a message, where the length of the body is greater than 4000, the substring(0,4000) function is called, but the result is not written back to the commentToAdd variable - so the full message is further processed, and the action log is not added to the workitem. --- smletsExchangeConnector.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index bb8c3d5b..8fe326fb 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -1555,7 +1555,7 @@ function Update-WorkItem $commentToAdd = $message.body if ($commentToAdd.length -ge "4000") { - $commentToAdd.substring(0, 4000) + $commentToAdd = $commentToAdd.substring(0, 4000) } } else @@ -1568,7 +1568,7 @@ function Update-WorkItem $commentToAdd = $message.body if ($commentToAdd.length -ge "4000") { - $commentToAdd.substring(0, 4000) + $commentToAdd = $commentToAdd.substring(0, 4000) } } else @@ -1576,7 +1576,7 @@ function Update-WorkItem $commentToAdd = $message.Body.substring(0, $fromKeywordPosition) if ($commentToAdd.length -ge "4000") { - $commentToAdd.substring(0, 4000) + $commentToAdd = $commentToAdd.substring(0, 4000) } } } From 8b275a068f602852bb73f41ccd841466b14e4ddc Mon Sep 17 00:00:00 2001 From: SimonZein <128088337+SimonZein@users.noreply.github.com> Date: Wed, 26 Apr 2023 01:35:48 +0200 Subject: [PATCH 3/7] Replace the ([R][E][:]) regex for Message merging with a multi language Regex (#453) * Update smletsExchangeConnector.ps1 * Update smletsExchangeConnector.ps1 * update reply regex adding square brackets to two of the reply regexes to be consistent with the rest of the patterns --------- Co-authored-by: Adam --- smletsExchangeConnector.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index 8fe326fb..9a9e8f83 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -918,6 +918,10 @@ if ($amlServiceRequestSupportGroupEnumPredictionExtName) } #endregion +#reply Regex +$replyRegex = '([R][E][:])|([A][W][:])|([S][V][:])|([A][n][t][w][:])|([V][S][:])|([R][E][F][:])|([V][á][:])|([R][I][F][:])|([S][V][:])|([B][L][S][:])|([A][t][b][\.][:])|([R][E][S][:])|([O][d][p][:])|([Y][N][T][:])|([A][T][B][:])' + + #region #### Exchange Connector Functions #### function New-WorkItem { @@ -5072,7 +5076,7 @@ foreach ($message in $inbox) #### Email is a Reply and does not contain a [Work Item ID] # Check if Work Item (Title, Body, Sender, CC, etc.) exists # and the user was replying too fast to receive Work Item ID notification - "([R][E][:])(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} + "($replyRegex)(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} #### default action, create work item #### default { @@ -5164,7 +5168,7 @@ foreach ($message in $inbox) #### Email is a Reply and does not contain a [Work Item ID] # Check if Work Item (Title, Body, Sender, CC, etc.) exists # and the user was replying too fast to receive Work Item ID notification - "([R][E][:])(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} + "($replyRegex)(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} #### Email is going to invoke a custom action. The signature MUST be valid to proceed "\[$powershellKeyword]" {if ($validSig -and $ceScripts) @@ -5260,7 +5264,7 @@ foreach ($message in $inbox) #### Email is a Reply and does not contain a [Work Item ID] # Check if Work Item (Title, Body, Sender, CC, etc.) exists # and the user was replying too fast to receive Work Item ID notification - "([R][E][:])(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} + "($replyRegex)(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} #### default action, create work item #### default { @@ -5335,7 +5339,7 @@ foreach ($message in $inbox) #### Email is a Reply and does not contain a [Work Item ID] # Check if Work Item (Title, Body, Sender, CC, etc.) exists # and the user was replying too fast to receive Work Item ID notification - "([R][E][:])(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} + "($replyRegex)(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} #### default action, create work item #### default { @@ -5421,7 +5425,7 @@ foreach ($message in $inbox) #### Email is a Reply and does not contain a [Work Item ID] # Check if Work Item (Title, Body, Sender, CC, etc.) exists # and the user was replying too fast to receive Work Item ID notification - "([R][E][:])(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} + "($replyRegex)(?!.*\[(($irRegex)|($srRegex)|($prRegex)|($crRegex)|($maRegex)|($raRegex))[0-9]+\])(.+)" {if(!($isUpdate)){if($mergeReplies -eq $true){Confirm-WorkItem -message $email}else{new-workitem -message $email -wiType $defaultNewWorkItem}}} #### default action, create work item #### default { From 7e14ce6888cb3b7481df27a4adda5a02c1b1ba0b Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 25 Apr 2023 18:37:28 -0500 Subject: [PATCH 4/7] move true/false value when loading Custom Events (#455) $true/$false values are incorrectly tied to the logging level used by the connector. This moves them out of that logic and ensures $ceScripts always has a value --- smletsExchangeConnector.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index 9a9e8f83..4c42548f 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -751,16 +751,16 @@ $ceScripts = if($smexcoSettingsMP.FilePathCustomEvents.EndsWith(".ps1")) if ($loggingLevel -ge 4) { New-SMEXCOEvent -Source "CustomEvents" -EventID 0 -Severity "Information" -LogMessage "Custom Events PowerShell loaded successfully" | out-null - $true } + $true } catch { if ($loggingLevel -ge 2) { New-SMEXCOEvent -Source "CustomEvents" -EventID 1 -Severity "Warning" -LogMessage $_.Exception | out-null - $false } + $false } } #endregion #### Configuration #### From 2b058b82c2a892db1e98e2cc3d942580fe0d28d5 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 25 Apr 2023 19:13:05 -0500 Subject: [PATCH 5/7] Warning, PSScriptAnalyzer Per PSScriptAnalyzer, this specific regex reply pattern is throwing a warning. It's possible this can be overcome, but short of further research/holding the release it's going to be removed for now. https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/usebomforunicodeencodedfile?view=ps-modules --- smletsExchangeConnector.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index 4c42548f..49733108 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -919,7 +919,7 @@ if ($amlServiceRequestSupportGroupEnumPredictionExtName) #endregion #reply Regex -$replyRegex = '([R][E][:])|([A][W][:])|([S][V][:])|([A][n][t][w][:])|([V][S][:])|([R][E][F][:])|([V][á][:])|([R][I][F][:])|([S][V][:])|([B][L][S][:])|([A][t][b][\.][:])|([R][E][S][:])|([O][d][p][:])|([Y][N][T][:])|([A][T][B][:])' +$replyRegex = '([R][E][:])|([A][W][:])|([S][V][:])|([A][n][t][w][:])|([V][S][:])|([R][E][F][:])|([R][I][F][:])|([S][V][:])|([B][L][S][:])|([A][t][b][\.][:])|([R][E][S][:])|([O][d][p][:])|([Y][N][T][:])|([A][T][B][:])' #region #### Exchange Connector Functions #### From 71aa8cee173d4945e8d21cc080050e48d9934f49 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 26 Apr 2023 09:22:18 -0500 Subject: [PATCH 6/7] contributors (#458) * powershell contributors updating powershell contributor list per pull requests/commits * update contributors on AboutForm.xaml updating the contributor list per pull requests/commits --- .../2016/SMLetsExchangeConnectorSettingsUI/Forms/AboutForm.xaml | 2 +- smletsExchangeConnector.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ManagementPack/2016/SMLetsExchangeConnectorSettingsUI/Forms/AboutForm.xaml b/ManagementPack/2016/SMLetsExchangeConnectorSettingsUI/Forms/AboutForm.xaml index 73c1b1a4..055b0369 100644 --- a/ManagementPack/2016/SMLetsExchangeConnectorSettingsUI/Forms/AboutForm.xaml +++ b/ManagementPack/2016/SMLetsExchangeConnectorSettingsUI/Forms/AboutForm.xaml @@ -14,7 +14,7 @@ + Peter Miklian, Daniel Polivka, Alexander Axberg, Simon Zeinhofer" /> diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index 49733108..755fcc34 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -10,7 +10,7 @@ enabling other organizational level processes via email .NOTES Author: Adam Dzyacky -Contributors: Martin Blomgren, Leigh Kilday, Tom Hendricks, nradler2, Justin Workman, Brad Zima, bennyguk, Jan Schulz, Peter Miklian, Daniel Polivka, Alexander Axberg +Contributors: Martin Blomgren, Leigh Kilday, Tom Hendricks, nradler2, Justin Workman, Brad Zima, bennyguk, Jan Schulz, Peter Miklian, Daniel Polivka, Alexander Axberg, Simon Zeinhofer Reviewers: Tom Hendricks, Brian Wiest Inspiration: The Cireson Community, Anders Asp, Stefan Roth, and (of course) Travis Wright for SMlets examples Requires: PowerShell 4+, SMlets, and Exchange Web Services API (already installed on SCSM workflow server by virtue of stock Exchange Connector). From a7fdf4e0613f3755bdb645dd4e74758a9a89aeb2 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 29 Apr 2023 11:38:22 -0500 Subject: [PATCH 7/7] version notes (#459) updating inline version notes with relevant issues/pull requests --- smletsExchangeConnector.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smletsExchangeConnector.ps1 b/smletsExchangeConnector.ps1 index 755fcc34..61f1f397 100644 --- a/smletsExchangeConnector.ps1 +++ b/smletsExchangeConnector.ps1 @@ -20,6 +20,11 @@ Requires: PowerShell 4+, SMlets, and Exchange Web Services API (already installe Signed/Encrypted option: .NET 4.5 is required to use MimeKit.dll Misc: The Release Record functionality does not exist in this as no out of box (or 3rd party) Type Projection exists to serve this purpose. You would have to create your own Type Projection in order to leverage this. +Version: 5.0.3 = #443 - Bug, Custom Events are incorrectly tied to a Logging Level + #453 - Enhancement, Merge Reply functionality supports multi-language environments + #452 - Bug, Fix for updating Work Items when the Comment is greater than 4000 characters + #456 - Bug, Mail is not added to comment when over 4000 characters + #447 - Bug, Fix for Templates that contain nested Activities Version: 5.0.2 = #444 - Bug, Fix for Templates that contain one or many Activities Version: 5.0.1 = #441 - Enhancement, Logging for when a user attempts to vote on a Review Activity that they are not a Reviewer on #440 - Enhancement, standardizing remaining functions param blocks and clarify logging event