Configure M365 Supplemental MailFlow Node

M365SMAIL.Configure.MailFlow.POSH.WA2 (WriteActionModuleType)

Will add registry settings so that nodes can become discovered. Once discovered, these objects will become targets for the ExchangeOnline and ExchangeHybrid workflows.

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsM365SL.RunAs.Profile
InputTypeSystem.BaseData
OutputTypeMicrosoft.Windows.SerializedObjectData

Member Modules:

ID Module Type TypeId RunAs 
POSH WriteAction Microsoft.Windows.PowerShellWriteAction Default

Overrideable Parameters:

IDParameterTypeSelector
DeleteConfigurationbool$Config/DeleteConfiguration$
M365_to_M365_IntervalSecondsstring$Config/M365_to_M365_IntervalSeconds$
M365_to_M365_ReceiveRetry_WaitSecondsstring$Config/M365_to_M365_ReceiveRetry_WaitSeconds$
M365_to_M365_ReceiveTimeoutSecondsstring$Config/M365_to_M365_ReceiveTimeoutSeconds$
M365_TotalDurationCriticalSecondsstring$Config/M365_TotalDurationCriticalSeconds$
M365_TotalDurationWarningSecondsstring$Config/M365_TotalDurationWarningSeconds$
Exchange_SenderEmailAddressstring$Config/Exchange_SenderEmailAddress$
Exchange_SenderPasswordstring$Config/Exchange_SenderPassword$
Exchange_ReceiverEmailAddressstring$Config/Exchange_ReceiverEmailAddress$
Exchange_ReceiverPasswordstring$Config/Exchange_ReceiverPassword$
Exchange_ReceiveTimeoutSecondsstring$Config/Exchange_ReceiveTimeoutSeconds$
ExchangeURLstring$Config/ExchangeURL$
ExchangeWebServicesPathstring$Config/ExchangeWebServicesPath$
M365_to_Exch_IntervalSecondsstring$Config/M365_to_Exch_IntervalSeconds$
M365_to_Exch_ReceiveRetry_WaitSecondsstring$Config/M365_to_Exch_ReceiveRetry_WaitSeconds$
Exch_to_M365_IntervalSecondsstring$Config/Exch_to_M365_IntervalSeconds$
Exch_to_M365_ReceiveRetry_WaitSecondsstring$Config/Exch_to_M365_ReceiveRetry_WaitSeconds$
Exch_TotalDurationCriticalSecondsstring$Config/Exch_TotalDurationCriticalSeconds$
Exch_TotalDurationWarningSecondsstring$Config/Exch_TotalDurationWarningSeconds$
M365_ClientIDstring$Config/M365_ClientID$
M365_ClientSecretstring$Config/M365_ClientSecret$
M365_ReceiverEmailAddressstring$Config/M365_ReceiverEmailAddress$
M365_ReceiverPasswordstring$Config/M365_ReceiverPassword$
M365_SenderEmailAddressstring$Config/M365_SenderEmailAddress$
M365_SenderPasswordstring$Config/M365_SenderPassword$
PoshLibraryPathstring$Config/PoshLibraryPath$
WriteActionTimeoutSecondsint$Config/WriteActionTimeoutSeconds$
WriteToEventLogbool$Config/WriteToEventLog$

Source Code:

<WriteActionModuleType ID="M365SMAIL.Configure.MailFlow.POSH.WA2" Accessibility="Internal" Batching="false" RunAs="M365SL!M365SL.RunAs.Profile">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="DeleteConfiguration" type="xsd:boolean"/>
<!--ExchangeOnline-->
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_to_M365_IntervalSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_to_M365_ReceiveRetry_WaitSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_to_M365_ReceiveTimeoutSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_TotalDurationCriticalSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_TotalDurationWarningSeconds" type="xsd:string"/>
<!--ExchangeHybrid-->
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exchange_SenderEmailAddress" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exchange_SenderPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exchange_ReceiverEmailAddress" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exchange_ReceiverPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exchange_ReceiveTimeoutSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ExchangeURL" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ExchangeWebServicesPath" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_to_Exch_IntervalSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_to_Exch_ReceiveRetry_WaitSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exch_to_M365_IntervalSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exch_to_M365_ReceiveRetry_WaitSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exch_TotalDurationCriticalSeconds" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Exch_TotalDurationWarningSeconds" type="xsd:string"/>
<!--Common-->
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_ClientID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_ClientSecret" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_ReceiverEmailAddress" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_ReceiverPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_SenderEmailAddress" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="M365_SenderPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TenantName" type="xsd:string"/>
<!--OTHER-->
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="MgmtGroupRegKey" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="OnDemandDiscovery" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="PoshLibraryPath" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="WorkflowName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="WriteActionTimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="WriteToEventLog" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="DeleteConfiguration" Selector="$Config/DeleteConfiguration$" ParameterType="bool"/>
<!--ExchangeOnline Controlled via Targt properties-->
<OverrideableParameter ID="M365_to_M365_IntervalSeconds" Selector="$Config/M365_to_M365_IntervalSeconds$" ParameterType="string"/>
<OverrideableParameter ID="M365_to_M365_ReceiveRetry_WaitSeconds" Selector="$Config/M365_to_M365_ReceiveRetry_WaitSeconds$" ParameterType="string"/>
<OverrideableParameter ID="M365_to_M365_ReceiveTimeoutSeconds" Selector="$Config/M365_to_M365_ReceiveTimeoutSeconds$" ParameterType="string"/>
<OverrideableParameter ID="M365_TotalDurationCriticalSeconds" Selector="$Config/M365_TotalDurationCriticalSeconds$" ParameterType="string"/>
<OverrideableParameter ID="M365_TotalDurationWarningSeconds" Selector="$Config/M365_TotalDurationWarningSeconds$" ParameterType="string"/>
<!--ExchangeHybrid Controlled via Targt properties-->
<OverrideableParameter ID="Exchange_SenderEmailAddress" Selector="$Config/Exchange_SenderEmailAddress$" ParameterType="string"/>
<OverrideableParameter ID="Exchange_SenderPassword" Selector="$Config/Exchange_SenderPassword$" ParameterType="string"/>
<OverrideableParameter ID="Exchange_ReceiverEmailAddress" Selector="$Config/Exchange_ReceiverEmailAddress$" ParameterType="string"/>
<OverrideableParameter ID="Exchange_ReceiverPassword" Selector="$Config/Exchange_ReceiverPassword$" ParameterType="string"/>
<OverrideableParameter ID="Exchange_ReceiveTimeoutSeconds" Selector="$Config/Exchange_ReceiveTimeoutSeconds$" ParameterType="string"/>
<OverrideableParameter ID="ExchangeURL" Selector="$Config/ExchangeURL$" ParameterType="string"/>
<OverrideableParameter ID="ExchangeWebServicesPath" Selector="$Config/ExchangeWebServicesPath$" ParameterType="string"/>
<OverrideableParameter ID="M365_to_Exch_IntervalSeconds" Selector="$Config/M365_to_Exch_IntervalSeconds$" ParameterType="string"/>
<OverrideableParameter ID="M365_to_Exch_ReceiveRetry_WaitSeconds" Selector="$Config/M365_to_Exch_ReceiveRetry_WaitSeconds$" ParameterType="string"/>
<OverrideableParameter ID="Exch_to_M365_IntervalSeconds" Selector="$Config/Exch_to_M365_IntervalSeconds$" ParameterType="string"/>
<OverrideableParameter ID="Exch_to_M365_ReceiveRetry_WaitSeconds" Selector="$Config/Exch_to_M365_ReceiveRetry_WaitSeconds$" ParameterType="string"/>
<OverrideableParameter ID="Exch_TotalDurationCriticalSeconds" Selector="$Config/Exch_TotalDurationCriticalSeconds$" ParameterType="string"/>
<OverrideableParameter ID="Exch_TotalDurationWarningSeconds" Selector="$Config/Exch_TotalDurationWarningSeconds$" ParameterType="string"/>
<!--Common Controlled via Targt properties-->
<OverrideableParameter ID="M365_ClientID" Selector="$Config/M365_ClientID$" ParameterType="string"/>
<OverrideableParameter ID="M365_ClientSecret" Selector="$Config/M365_ClientSecret$" ParameterType="string"/>
<OverrideableParameter ID="M365_ReceiverEmailAddress" Selector="$Config/M365_ReceiverEmailAddress$" ParameterType="string"/>
<OverrideableParameter ID="M365_ReceiverPassword" Selector="$Config/M365_ReceiverPassword$" ParameterType="string"/>
<OverrideableParameter ID="M365_SenderEmailAddress" Selector="$Config/M365_SenderEmailAddress$" ParameterType="string"/>
<OverrideableParameter ID="M365_SenderPassword" Selector="$Config/M365_SenderPassword$" ParameterType="string"/>
<!--OTHER-->
<OverrideableParameter ID="PoshLibraryPath" Selector="$Config/PoshLibraryPath$" ParameterType="string"/>
<OverrideableParameter ID="WriteActionTimeoutSeconds" Selector="$Config/WriteActionTimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="WriteToEventLog" Selector="$Config/WriteToEventLog$" ParameterType="bool"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="POSH" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>ConfigureM365MailFlow.ps1</ScriptName>
<ScriptBody><Script>&lt;#
Script: ConfigureM365MailFlow.ps1
Description: Will configure registry settings to enable discovery of MailFlow nodes
Author: Tyson Paul
Blog: MonitoringGuys.com
Version History:
2021.08.05.1606 - Modified params (ints to strings), added code for OnDemand discovery.
2021.05.04.1614 - Added LastModified to reg data.
2020.11.25.1022 - Added TotalDurationWarningSeconds, TotalDurationCriticalSeconds
2020.11.06.1660 - Added ability to delete configuration.
2020.09.24.1613 - Updated with Load-Libary. Cleaned up comments.
2020.09.22.0001 - Implemented functions. - for ClientSecret and Password formatting (skipping w/-1)
2020.09.16.1652 - Improved space ' ' filtering in AddRegData section.
2020.09.15.1536 - Added additional params for hybrid sender/receiver passwords and Exchangewebservices DLL.
2020.09.02.1731 - Improved logic to skip values with negative numbers or whitespace char.
2020.08.20.1628 - Updated with additional params. Removed 'Enabled' param.
2020.07.29 -
2020.05.23 - v1.0
#&gt;
########################################################################################################

Param(
#ExchangeOnline
[string]$M365_to_M365_IntervalSeconds,
[string]$M365_to_M365_ReceiveRetry_WaitSeconds,
[string]$M365_to_M365_ReceiveTimeoutSeconds,
[string]$M365_TotalDurationCriticalSeconds,
[string]$M365_TotalDurationWarningSeconds,

#ExchangeHybrid
[string]$Exchange_SenderEmailAddress,
[string]$Exchange_SenderPassword,
[string]$Exchange_ReceiverEmailAddress,
[string]$Exchange_ReceiverPassword,
[string]$Exchange_ReceiveTimeoutSeconds,
[string]$ExchangeURL,
[string]$ExchangeWebServicesPath,
[string]$M365_to_Exch_IntervalSeconds,
[string]$M365_to_Exch_ReceiveRetry_WaitSeconds,
[string]$Exch_to_M365_IntervalSeconds,
[string]$Exch_to_M365_ReceiveRetry_WaitSeconds,
[string]$Exch_TotalDurationCriticalSeconds,
[string]$Exch_TotalDurationWarningSeconds,

#Common
[string]$TenantName ,
[string]$M365_ClientID,
[string]$M365_ClientSecret,
[string]$M365_SenderEmailAddress,
[string]$M365_SenderPassword,
[string]$M365_ReceiverEmailAddress,
[string]$M365_ReceiverPassword,


#OTHER
[string]$DeleteConfiguration = 'false',
[string]$MgmtGroupRegKey = '',
[string]$OnDemandDiscovery,
[string]$PoshLibraryPath, #comma-separated list of .ps1 files to load
[string]$WorkflowName = '&lt;No WorkflowName provided&gt;',
[string]$WriteToEventLog = 'false'
)

[bool]$WriteToEventLog = [System.Convert]::ToBoolean($WriteToEventLog)
[bool]$DeleteConfiguration = [System.Convert]::ToBoolean($DeleteConfiguration)
[string]$ScriptName = 'ConfigureM365MailFlow.ps1'
$NameSpace = 'MailFlow'

######################### FUNCTIONS ############################
################################################################
Function Load-Library {
Param (
[string]$PoshLibraryPath
)
$ErrorActionPreference = 'STOP'
If (-NOT $NameSpace.Length) {
$NameSpace = $ScriptName
}
$EventSource = "M365 Supplemental"
$EventLogName = "Application"
$objEvent = New-Object System.Diagnostics.EventLog
$objEvent.Source = $EventSource
$objEvent.Log = $EventLogName
$EventID_Normal = 9992
$EventID_Anomaly = 9996
[Int]$info=4 #System.Diagnostics.EventInstance
[Int]$critical=1
[Int]$warn=2

If ($PoshLibraryPath ){
Start-Sleep -Seconds 5 #Allow time for Library to be deployed
Start-Sleep -Seconds 5 #Allow time for Library to be deployed
ForEach ($Path in $PoshLibraryPath.Split(',') ){
Try {
If (($Path.Length) -AND ($Path -notmatch '^-1$')) {
. $Path
If ([bool]$WriteToEventLog -eq $true) {
$msg = "Line [$($MyInvocation.ScriptLineNumber)], $($MyInvocation.PSCommandPath): Success loading library file: [$($Path)]"
$logData = "$($Msg)^$($Msg)^$($ScriptName)^$($TenantName)^$($NameSpace)"
[array]$arrMessage = @($logData.Split('^'))
$objEventID = New-Object System.Diagnostics.EventInstance($EventID_Normal,1,$info)
$objEvent.WriteEvent($objEventID, @($arrMessage))
}
}
} Catch {
[bool]$LibExists =$false
Try {
# It's possible the libfile exists (as it should) but cannot be loaded for some reason.
[bool]$LibExists = [bool](Test-Path -Path $Path -PathType Leaf)
} Catch {
#File does not exist. LibExists = $false already by default
}
$msg = "Line [$($MyInvocation.ScriptLineNumber )]: Error loading PoshLibrary at path:[$($Path)]. Library file exists? [$($LibExists)]. This is likely to cause many other dependent functions to fail. `n`nError data: $($_)`n`n"
$logData = "$($Msg)^$($Msg)^$($ScriptName)^$($TenantName)^$($NameSpace)"
[array]$arrMessage = @($logData.Split('^'))
$objEventID = New-Object System.Diagnostics.EventInstance($EventID_Anomaly,1,$warn)
$objEvent.WriteEvent($objEventID, @($arrMessage))
}
}
}
$ErrorActionPreference = 'CONTINUE'
}
################################################################

############## TESTING ##############
&lt;# #Run this as needed when testing

#---------------------------------------
Function Testing {
$Testing = $true
$testParamsFile = (Join-path $TestFolder ("PARAMS_$($ScriptName)"))
#Write-Host "$(Test-Path $testParamsFile):$($testParamsFile)" -F Yellow -B Green
. $testParamsFile
. Load-Library -PoshLibraryPath $PoshLibraryPath

# Encode user data/passwords in current test user context
$M365_ClientSecret = Encode-UserData $M365_ClientSecret_PLAINTEXT
$M365_AccountPassword = Encode-UserData $M365_AccountPassword_PLAINTEXT
$error.Clear()
LogIt -EventID 9995 -Type $warn -Proceed $true -msg "TESTING ENABLED. Test file used: [$($testFile)]" -LINE $(_LINE_); $Error.Clear()
}
#---------------------------------------

$TestFolder = "C:\Test\M365SMP_Dev\$($NameSpace)\TestSetup"
If (Test-Path -Path $TestFolder) {
. Testing
}
#&gt;


. Load-Library -PoshLibraryPath $PoshLibraryPath

###################### Main ##############################
$Message = "Script begin... "
LogIt -EventID 9990 -Type $info -Msg $Message -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
Write-Output "Computer: $([System.Net.Dns]::GetHostByName($env:computerName).HostName)"

# Will exit if TenantName is not valid
Verify-TenantName -TenantName $TenantName -MgmtGroupRegKey $MgmtGroupRegKey

$TenantKey = Join-Path $MgmtGroupRegKey $TenantName
$RegKey = Join-Path $TenantKey $NameSpace
LogIt -EventID 9990 -Type $info -Msg "Reg Key set to [$($RegKey)]" -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()

# Will proceed to delete config if appropriate. This function is designed to be run dot-sourced
. Verify-ShouldDeleteConfiguration

LogIt -EventID 9992 -Type $info -Msg "Formatting ClientSecret..." -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
$M365_ClientSecret_ENCRYPTED = Format-ClientSecret -M365_ClientSecret $M365_ClientSecret

LogIt -EventID 9992 -Type $info -Msg "Encrypting password for account: [$($Exchange_SenderEmailAddress)]..." -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
$Exchange_SenderPassword_ENCRYPTED = Encrypt-PlainAccountPassword -passwdString $Exchange_SenderPassword

LogIt -EventID 9992 -Type $info -Msg "Encrypting password for account: [$($Exchange_ReceiverEmailAddress)]..." -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
$Exchange_ReceiverPassword_ENCRYPTED = Encrypt-PlainAccountPassword -passwdString $Exchange_ReceiverPassword

LogIt -EventID 9992 -Type $info -Msg "Encrypting password for account: [$($M365_SenderEmailAddress)]..." -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
$M365_SenderPassword_ENCRYPTED = Encrypt-PlainAccountPassword -passwdString $M365_SenderPassword

LogIt -EventID 9992 -Type $info -Msg "Encrypting password for account: [$($M365_ReceiverEmailAddress)]..." -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
$M365_ReceiverPassword_ENCRYPTED = Encrypt-PlainAccountPassword -passwdString $M365_ReceiverPassword

# This section will set basic config reg info for a M365SL.WatcherNode
#region regsettingshash
$NewSettings = [ordered]@{

'LastModified' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = ((Get-Date -Format F).ToString())
}

######## ExchangeOnline ########
'M365_to_M365_IntervalSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_to_M365_IntervalSeconds
}

'M365_to_M365_ReceiveRetry_WaitSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_to_M365_ReceiveRetry_WaitSeconds
}

'M365_to_M365_ReceiveTimeoutSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_to_M365_ReceiveTimeoutSeconds
}


####### ExchangeHybrid #######
#create these reg Values even if vars are empty. Hybrid discovery is based on existence of ExchangeURL valuedata. If empty, no discovery of Hybrid instance. Easy peasy.

'Exchange_ReceiverEmailAddress' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $Exchange_ReceiverEmailAddress
}

'Exchange_ReceiverPassword' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $Exchange_ReceiverPassword_ENCRYPTED
}

'Exchange_ReceiveTimeoutSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $Exchange_ReceiveTimeoutSeconds
}

'Exchange_SenderEmailAddress' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $Exchange_SenderEmailAddress
}

'Exchange_SenderPassword' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $Exchange_SenderPassword_ENCRYPTED
}

'ExchangeURL' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $ExchangeURL
}

'ExchangeWebServicesPath' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $ExchangeWebServicesPath
}

'M365_to_Exch_IntervalSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_to_Exch_IntervalSeconds
}

'M365_to_Exch_ReceiveRetry_WaitSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_to_Exch_ReceiveRetry_WaitSeconds
}

'Exch_to_M365_IntervalSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $Exch_to_M365_IntervalSeconds
}

'Exch_to_M365_ReceiveRetry_WaitSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $Exch_to_M365_ReceiveRetry_WaitSeconds
}


# COMMON
'M365_SenderEmailAddress' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $M365_SenderEmailAddress
}

'M365_SenderPassword' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $M365_SenderPassword_ENCRYPTED
}

'M365_ReceiverEmailAddress' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $M365_ReceiverEmailAddress
}

'M365_ReceiverPassword' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $M365_ReceiverPassword_ENCRYPTED
}

'M365_ClientID' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $M365_ClientID
}

'M365_ClientSecret' = @{
Key = $RegKey
ValueType = 'REG_SZ'
ValueData = $M365_ClientSecret_ENCRYPTED
}

'M365_TotalDurationCriticalSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_TotalDurationCriticalSeconds
}

'M365_TotalDurationWarningSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $M365_TotalDurationWarningSeconds
}

'Exch_TotalDurationCriticalSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $Exch_TotalDurationCriticalSeconds
}

'Exch_TotalDurationWarningSeconds' = @{
Key = $RegKey
ValueType = 'REG_DWORD'
ValueData = $Exch_TotalDurationWarningSeconds
}
}
#endregion regsettingshash

# Add Settings
LogIt -EventID 9992 -Type $info -Msg "Proceed to add registry data at key: [$($RegKey)] " -Proceed $WriteToEventLog -LINE $(_LINE_); $Error.Clear()
Create-RegistryEntries -NewSettings $NewSettings
Write-OnDemandDiscoveryEvent
LogIt -EventID 9991 -Type $info -Proceed $WriteToEventLog -msg "Script End. Finished in [$($ScriptTimer.Elapsed.TotalSeconds)] seconds. `n" -LINE $(_LINE_)
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>DeleteConfiguration</Name>
<Value>$Config/DeleteConfiguration$</Value>
</Parameter>
<!--ExchangeOnline-->
<Parameter>
<Name>M365_to_M365_IntervalSeconds</Name>
<Value>$Config/M365_to_M365_IntervalSeconds$</Value>
</Parameter>
<Parameter>
<Name>M365_to_M365_ReceiveRetry_WaitSeconds</Name>
<Value>$Config/M365_to_M365_ReceiveRetry_WaitSeconds$</Value>
</Parameter>
<Parameter>
<Name>M365_to_M365_ReceiveTimeoutSeconds</Name>
<Value>$Config/M365_to_M365_ReceiveTimeoutSeconds$</Value>
</Parameter>
<Parameter>
<Name>M365_TotalDurationCriticalSeconds</Name>
<Value>$Config/M365_TotalDurationCriticalSeconds$</Value>
</Parameter>
<Parameter>
<Name>M365_TotalDurationWarningSeconds</Name>
<Value>$Config/M365_TotalDurationWarningSeconds$</Value>
</Parameter>
<!--ExchangeHybrid-->
<Parameter>
<Name>Exchange_SenderEmailAddress</Name>
<Value>$Config/Exchange_SenderEmailAddress$</Value>
</Parameter>
<Parameter>
<Name>Exchange_SenderPassword</Name>
<Value>$Config/Exchange_SenderPassword$</Value>
</Parameter>
<Parameter>
<Name>Exchange_ReceiverEmailAddress</Name>
<Value>$Config/Exchange_ReceiverEmailAddress$</Value>
</Parameter>
<Parameter>
<Name>Exchange_ReceiverPassword</Name>
<Value>$Config/Exchange_ReceiverPassword$</Value>
</Parameter>
<Parameter>
<Name>Exchange_ReceiveTimeoutSeconds</Name>
<Value>$Config/Exchange_ReceiveTimeoutSeconds$</Value>
</Parameter>
<Parameter>
<Name>ExchangeURL</Name>
<Value>$Config/ExchangeURL$</Value>
</Parameter>
<Parameter>
<Name>ExchangeWebServicesPath</Name>
<Value>$Config/ExchangeWebServicesPath$</Value>
</Parameter>
<Parameter>
<Name>M365_to_Exch_IntervalSeconds</Name>
<Value>$Config/M365_to_Exch_IntervalSeconds$</Value>
</Parameter>
<Parameter>
<Name>M365_to_Exch_ReceiveRetry_WaitSeconds</Name>
<Value>$Config/M365_to_Exch_ReceiveRetry_WaitSeconds$</Value>
</Parameter>
<Parameter>
<Name>Exch_to_M365_IntervalSeconds</Name>
<Value>$Config/Exch_to_M365_IntervalSeconds$</Value>
</Parameter>
<Parameter>
<Name>Exch_to_M365_ReceiveRetry_WaitSeconds</Name>
<Value>$Config/Exch_to_M365_ReceiveRetry_WaitSeconds$</Value>
</Parameter>
<Parameter>
<Name>Exch_TotalDurationCriticalSeconds</Name>
<Value>$Config/Exch_TotalDurationCriticalSeconds$</Value>
</Parameter>
<Parameter>
<Name>Exch_TotalDurationWarningSeconds</Name>
<Value>$Config/Exch_TotalDurationWarningSeconds$</Value>
</Parameter>
<!--Common-->
<Parameter>
<Name>TenantName</Name>
<Value>$Config/TenantName$</Value>
</Parameter>
<Parameter>
<Name>M365_ClientID</Name>
<Value>$Config/M365_ClientID$</Value>
</Parameter>
<Parameter>
<Name>M365_ClientSecret</Name>
<Value>$Config/M365_ClientSecret$</Value>
</Parameter>
<Parameter>
<Name>M365_SenderEmailAddress</Name>
<Value>$Config/M365_SenderEmailAddress$</Value>
</Parameter>
<Parameter>
<Name>M365_SenderPassword</Name>
<Value>$Config/M365_SenderPassword$</Value>
</Parameter>
<Parameter>
<Name>M365_ReceiverEmailAddress</Name>
<Value>$Config/M365_ReceiverEmailAddress$</Value>
</Parameter>
<Parameter>
<Name>M365_ReceiverPassword</Name>
<Value>$Config/M365_ReceiverPassword$</Value>
</Parameter>
<!--OTHER-->
<Parameter>
<Name>MgmtGroupRegKey</Name>
<Value>$Config/MgmtGroupRegKey$</Value>
</Parameter>
<Parameter>
<Name>OnDemandDiscovery</Name>
<Value>$Config/OnDemandDiscovery$</Value>
</Parameter>
<Parameter>
<Name>PoshLibraryPath</Name>
<Value>$FileResource[Name='Res.M365SMAIL.M365Library.ps1.Resource']/Path$,$Config/PoshLibraryPath$</Value>
</Parameter>
<Parameter>
<Name>WorkflowName</Name>
<Value>$Config/WorkflowName$</Value>
</Parameter>
<Parameter>
<Name>WriteToEventLog</Name>
<Value>$Config/WriteToEventLog$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/WriteActionTimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="POSH"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>Windows!Microsoft.Windows.SerializedObjectData</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>