From 860b095e4d0646b39c7f40f8e49a431fd0a32ebd Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 29 Apr 2023 12:41:01 -0500 Subject: [PATCH] v5.0.3 (#457) * Fix for Templates with nested Activities (#447) Added -Alias $alias to the recursive Update-SCSMPropertyCollection call * 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. * 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 * 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 * 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 * 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 * version notes (#459) updating inline version notes with relevant issues/pull requests --------- Co-authored-by: SimonZein <128088337+SimonZein@users.noreply.github.com> --- .../Forms/AboutForm.xaml | 2 +- smletsExchangeConnector.ps1 | 33 ++++++++++++------- 2 files changed, 22 insertions(+), 13 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 3ef8ad05..61f1f397 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). @@ -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 @@ -751,16 +756,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 #### @@ -918,6 +923,10 @@ if ($amlServiceRequestSupportGroupEnumPredictionExtName) } #endregion +#reply Regex +$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 #### function New-WorkItem { @@ -1555,7 +1564,7 @@ function Update-WorkItem $commentToAdd = $message.body if ($commentToAdd.length -ge "4000") { - $commentToAdd.substring(0, 4000) + $commentToAdd = $commentToAdd.substring(0, 4000) } } else @@ -1568,7 +1577,7 @@ function Update-WorkItem $commentToAdd = $message.body if ($commentToAdd.length -ge "4000") { - $commentToAdd.substring(0, 4000) + $commentToAdd = $commentToAdd.substring(0, 4000) } } else @@ -1576,7 +1585,7 @@ function Update-WorkItem $commentToAdd = $message.Body.substring(0, $fromKeywordPosition) if ($commentToAdd.length -ge "4000") { - $commentToAdd.substring(0, 4000) + $commentToAdd = $commentToAdd.substring(0, 4000) } } } @@ -4611,7 +4620,7 @@ function Update-SCSMPropertyCollection { foreach ($obj in $Object.ObjectCollection) { - Update-SCSMPropertyCollection -Object $obj + Update-SCSMPropertyCollection -Object $obj -Alias $alias } } } @@ -5072,7 +5081,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 +5173,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 +5269,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 +5344,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 +5430,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 {