Skip to content

Commit

Permalink
v5.0.3 (#457)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
AdhocAdam and SimonZein committed Apr 29, 2023
1 parent 5e2f85a commit 860b095
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
Expand Up @@ -14,7 +14,7 @@
<!-- Contributors -->
<TextBlock Margin="0,5,0,0" TextWrapping="Wrap" FontStyle="Italic" Text="SMLets Exchange Connector (PowerShell) Contributors" />
<TextBlock Margin="10,0" TextWrapping="Wrap" Text="Martin Blomgren, Tom Hendricks, Leigh Kilday, nradler2, Justin Workman, Brad Zima, bennyguk, Jan Schulz,
Peter Miklian, Daniel Polivka, Alexander Axberg" />
Peter Miklian, Daniel Polivka, Alexander Axberg, Simon Zeinhofer" />
<!-- Reviewers -->
<TextBlock Margin="0,5,0,0" TextWrapping="Wrap" FontStyle="Italic" Text="SMLets Exchange Connector (PowerShell) Reviewers" />
<TextBlock Margin="10,0" TextWrapping="Wrap" Text="Tom Hendricks, Brian Wiest" />
Expand Down
33 changes: 21 additions & 12 deletions smletsExchangeConnector.ps1
Expand Up @@ -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).
Expand All @@ -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
Expand Down Expand Up @@ -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 ####
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand All @@ -1568,15 +1577,15 @@ function Update-WorkItem
$commentToAdd = $message.body
if ($commentToAdd.length -ge "4000")
{
$commentToAdd.substring(0, 4000)
$commentToAdd = $commentToAdd.substring(0, 4000)
}
}
else
{
$commentToAdd = $message.Body.substring(0, $fromKeywordPosition)
if ($commentToAdd.length -ge "4000")
{
$commentToAdd.substring(0, 4000)
$commentToAdd = $commentToAdd.substring(0, 4000)
}
}
}
Expand Down Expand Up @@ -4611,7 +4620,7 @@ function Update-SCSMPropertyCollection
{
foreach ($obj in $Object.ObjectCollection)
{
Update-SCSMPropertyCollection -Object $obj
Update-SCSMPropertyCollection -Object $obj -Alias $alias
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 860b095

Please sign in to comment.