When using input parameters to the script
################################################## INPUT#################################################Param(
[hashtable] $params
)
#-----------------------------------------------# DEBUG SWITCH#-----------------------------------------------$debug=$false#-----------------------------------------------# INPUT PARAMETERS, IF DEBUG IS TRUE#-----------------------------------------------if ( $debug ) {
$params= [hashtable]@{
EmailFieldName="Email"TransactionType="Replace"scriptPath="C:\Apteco\Integration\MSSQL"ReplyToEmail=""database="dev"
}
}
################################################## SCRIPT ROOT#################################################if ( $debug ) {
# Load scriptpathif ($MyInvocation.MyCommand.CommandType-eq"ExternalScript") {
$scriptPath=Split-Path-Parent -Path $MyInvocation.MyCommand.Definition
} else {
$scriptPath=Split-Path-Parent -Path ([Environment]::GetCommandLineArgs()[0])
}
} else {
$scriptPath="$($params.scriptPath)" }
Set-Location-Path $scriptPath################################################## SETTINGS################################################## General settings$functionsSubfolder="functions"$settingsFilename="settings.json"$processId= [guid]::NewGuid()
$moduleName="GETMAILINGS"# Load settings$settings=Get-Content-Path "$($scriptPath)\$($settingsFilename)"-Encoding UTF8 -Raw |ConvertFrom-Json# append a suffix, if in debug modeif ( $debug ) {
$logfile="$($logfile).debug"
}################################################## FUNCTIONS#################################################Get-ChildItem".\$($functionsSubfolder)"-Filter "*.ps1"-Recurse |ForEach {
.$_.FullName
}if ( $settings.changeTLS ) {
$AllProtocols=@( [System.Net.SecurityProtocolType]::Tls12
#[System.Net.SecurityProtocolType]::Tls13,,[System.Net.SecurityProtocolType]::Ssl3
)
[System.Net.ServicePointManager]::SecurityProtocol =$AllProtocols
}