EDiscoveryTools.psm1

$script:ModuleRoot = $PSScriptRoot
$script:ModuleVersion = (Import-PowerShellDataFile -Path "$($script:ModuleRoot)\EDiscoveryTools.psd1").ModuleVersion

# Detect whether at some level dotsourcing was enforced
$script:doDotSource = Get-PSFConfigValue -FullName EDiscoveryTools.Import.DoDotSource -Fallback $false
if ($EDiscoveryTools_dotsourcemodule) { $script:doDotSource = $true }

<#
Note on Resolve-Path:
All paths are sent through Resolve-Path/Resolve-PSFPath in order to convert them to the correct path separator.
This allows ignoring path separators throughout the import sequence, which could otherwise cause trouble depending on OS.
Resolve-Path can only be used for paths that already exist, Resolve-PSFPath can accept that the last leaf my not exist.
This is important when testing for paths.
#>


# Detect whether at some level loading individual module files, rather than the compiled module was enforced
$importIndividualFiles = Get-PSFConfigValue -FullName EDiscoveryTools.Import.IndividualFiles -Fallback $false
if ($EDiscoveryTools_importIndividualFiles) { $importIndividualFiles = $true }
if (Test-Path (Resolve-PSFPath -Path "$($script:ModuleRoot)\..\.git" -SingleItem -NewChild)) { $importIndividualFiles = $true }
if ("<was compiled>" -eq '<was not compiled>') { $importIndividualFiles = $true }
    
function Import-ModuleFile
{
    <#
        .SYNOPSIS
            Loads files into the module on module import.
         
        .DESCRIPTION
            This helper function is used during module initialization.
            It should always be dotsourced itself, in order to proper function.
             
            This provides a central location to react to files being imported, if later desired
         
        .PARAMETER Path
            The path to the file to load
         
        .EXAMPLE
            PS C:\> . Import-ModuleFile -File $function.FullName
     
            Imports the file stored in $function according to import policy
    #>

    [CmdletBinding()]
    Param (
        [string]
        $Path
    )
    
    $resolvedPath = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($Path).ProviderPath
    if ($doDotSource) { . $resolvedPath }
    else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($resolvedPath))), $null, $null) }
}

#region Load individual files
if ($importIndividualFiles)
{
    # Execute Preimport actions
    . Import-ModuleFile -Path "$ModuleRoot\internal\scripts\preimport.ps1"
    
    # Import all internal functions
    foreach ($function in (Get-ChildItem "$ModuleRoot\internal\functions" -Filter "*.ps1" -Recurse -ErrorAction Ignore))
    {
        . Import-ModuleFile -Path $function.FullName
    }
    
    # Import all public functions
    foreach ($function in (Get-ChildItem "$ModuleRoot\functions" -Filter "*.ps1" -Recurse -ErrorAction Ignore))
    {
        . Import-ModuleFile -Path $function.FullName
    }
    
    # Execute Postimport actions
    . Import-ModuleFile -Path "$ModuleRoot\internal\scripts\postimport.ps1"
    
    # End it here, do not load compiled code below
    return
}
#endregion Load individual files

#region Load compiled code
<#
This file loads the strings documents from the respective language folders.
This allows localizing messages and errors.
Load psd1 language files for each language you wish to support.
Partial translations are acceptable - when missing a current language message,
it will fallback to English or another available language.
#>

Import-PSFLocalizedString -Path "$($script:ModuleRoot)\en-us\*.psd1" -Module 'EDiscoveryTools' -Language 'en-US'

function Assert-Connection
{
<#
    .SYNOPSIS
        Ensures a connection to the Office 365 Compliance Center has been established.
     
    .DESCRIPTION
        Ensures a connection to the Office 365 Compliance Center has been established.
     
    .EXAMPLE
        PS C:\> Assert-Connection
     
        Ensures a connection to the Office 365 Compliance Center has been established.
#>

    [CmdletBinding()]
    Param (
    
    )
    
    process
    {
        if (-not $script:connected)
        {
            Connect-EDiscovery
        }
    }
}

function Connect-EDiscovery
{
<#
    .SYNOPSIS
        Connects to the Office 365 Compliance Center.
     
    .DESCRIPTION
        Connects to the Office 365 Compliance Center.
        This uses modern authentication to ensure continued functionality.
     
        Behind the scenes, this uses the ExchangeOnlineManagement module to ensure continued support.
        Functionally, this establishes a PowerShell remoting session to the destination endpoint and imports the required commands.
     
        Note: Due to implementation details of EOM, using other PowerShell remoting sessions in the same runspace is not supported at the current time.
     
    .PARAMETER Credential
        Credentials to use for authentication.
        Cannot be used for MFA bound accounts.
     
    .PARAMETER Uri
        A custom URI to use when connecting to the service.
        Generally needs not be changed.
     
    .PARAMETER Confirm
        If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
     
    .PARAMETER WhatIf
        If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
     
    .EXAMPLE
        PS C:\> Connect-EDiscovery
     
        Connects to the Office 365 Compliance Center, prompting for user credentials.
#>

    [CmdletBinding(SupportsShouldProcess = $true)]
    param (
        [System.Management.Automation.PSCredential]
        $Credential,
        
        [string]
        $Uri = (Get-PSFConfigValue -FullName 'EDiscoveryTools.Connection.Uri')
    )
    
    begin
    {
        $params = @{
            ConnectionUri = $Uri
            WarningAction = 'SilentlyContinue'
        }
        if ($Credential) { $params['Credential'] = $Credential }
        
        if (-not $script:defaultGroupMappingDataImported)
        {
            if (Get-PSFConfigValue -FullName 'EDiscoveryTools.Search.Config.Path') { Import-EDisSearchTag }
            else { Write-PSFMessage -Level Warning -String 'Connect-EDiscovery.Config.NoSearchPath' -Once 'Search' }
        }
    }
    process
    {
        Invoke-PSFProtectedCommand -ActionString 'Connect-EDiscovery.Connecting' -Target 'Compliance Center' -ScriptBlock {
            Connect-ExchangeOnline @params -ErrorAction Stop
            $script:connected = $true
        } -EnableException $true -PSCmdlet $PSCmdlet
    }
}

function Import-EDisSearchTag
{
<#
    .SYNOPSIS
        Imports a name mapping file used for creating searches.
     
    .DESCRIPTION
        Imports a name mapping file used for creating searches.
        See Register-EDisSearchTag for details on format of input.
        Imports the configured default config if no path is specified.
     
    .PARAMETER Path
        Path to a configuration file to import.
        If this parameter is omitted, the default configured file specified through Register-EDisSearchTag is used instead.
     
    .PARAMETER Type
        The type of file specified.
        If not specified, it will try to use the file extension to determine type.
        If that too fails, it will default to csv.
     
    .PARAMETER EnableException
        This parameters disables user-friendly warnings and enables the throwing of exceptions.
        This is less user friendly, but allows catching exceptions in calling scripts.
     
    .EXAMPLE
        PS C:\> Import-EDisSearchTag
     
        Imports the default search group mapping.
     
    .EXAMPLE
        PS C:\> Import-EDisSearchTag -Path .\config.json
     
        Imports the search group mapping stored in config.json.
#>

    [CmdletBinding()]
    Param (
        [PsfValidateScript('EDiscovery.Validate.Path', ErrorString = 'EDiscovery.Validate.Path.Failed')]
        [string]
        $Path,
        
        [ValidateSet('csv', 'json', 'xml')]
        [string]
        $Type,
        
        [switch]
        $EnableException
    )
    
    begin
    {
        function Import-CsvConfig
        {
            [CmdletBinding()]
            param (
                [string]
                $Path
            )
            foreach ($entry in (Import-Csv -Path $Path -Delimiter "," -Encoding UTF8 -ErrorAction Stop))
            {
                if (-not ($entry.Tag -and $entry.Group)) { throw "Invalid CSV file!" }
                
                if ($script:searchGroupMappingData[$entry.Tag])
                {
                    $script:searchGroupMappingData[$entry.Tag] = $script:searchGroupMappingData[$entry.Tag], $entry.Group | Write-Output | Select-Object -Unique
                }
                else
                {
                    $script:searchGroupMappingData[$entry.Tag] = $entry.Group
                }
            }
        }
        function Import-JsonConfig
        {
            [CmdletBinding()]
            param (
                [string]
                $Path
            )
            $data = Get-Content -Path $Path -Encoding UTF8 -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
            foreach ($entry in ($data.PSObject.Properties.Name))
            {
                if (-not $data.$entry) { throw "Invalid json file!" }
                
                if ($script:searchGroupMappingData[$entry])
                {
                    $script:searchGroupMappingData[$entry] = $script:searchGroupMappingData[$entry], $data.$entry | Write-Output | Select-Object -Unique
                }
                else
                {
                    $script:searchGroupMappingData[$entry] = $data.$entry
                }
            }
        }
        function Import-XmlConfig
        {
            [CmdletBinding()]
            param (
                [string]
                $Path
            )
            [xml]$data = Get-Content -Path $Path -Encoding UTF8 -ErrorAction Stop
            if (-not $data.entries.entry) { throw "Invalid XML configuration file!" }
            
            foreach ($entry in $xml.entries.entry)
            {
                if (-not ($entry.Tag -and $entry.Group)) { throw "Invalid XML configuration entry!" }
                
                if ($script:searchGroupMappingData[$entry.Tag])
                {
                    $script:searchGroupMappingData[$entry.Tag] = $script:searchGroupMappingData[$entry.Tag], $entry.Group | Write-Output | Select-Object -Unique
                }
                else
                {
                    $script:searchGroupMappingData[$entry.Tag] = $entry.Group
                }
            }
        }
    }
    process
    {
        if ($Path)
        {
            $importPath = Resolve-PSFPath -Path $Path -Provider FileSystem -SingleItem
            $selectedType = $Type
            if (Test-PSFParameterBinding -ParameterName Type -Not)
            {
                $item = Get-Item -LiteralPath $importPath
                switch ($item.Extension)
                {
                    '.Json' { $selectedType = 'Json' }
                    '.Xml' { $selectedType = 'Xml' }
                    default { $selectedType = 'Csv' }
                }
            }
            try
            {
                switch ($selectedType)
                {
                    'Json' { Import-JsonConfig -Path $importPath }
                    'Xml' { Import-XmlConfig -Path $importPath }
                    default { Import-CsvConfig -Path $importPath }
                }
            }
            catch
            {
                Stop-PSFFunction -String Import-EDisSearchTag.DefaultImport.Failed -StringValues $importPath -EnableException $EnableException -Cmdlet $PSCmdlet -ErrorRecord $_
                return
            }
        }
        else
        {
            $importPath = Get-PSFConfigValue -FullName 'EDiscoveryTools.Search.Config.Path'
            if (-not $importPath)
            {
                Stop-PSFFunction -String Import-EDisSearchTag.DefaultImport.NoConfig -EnableException $EnableException -Cmdlet $PSCmdlet
                return
            }
            if (-not (Test-Path $importPath))
            {
                Stop-PSFFunction -String Import-EDisSearchTag.DefaultImport.PathNotExists -StringValues $importPath -EnableException $EnableException -Cmdlet $PSCmdlet
                return
            }
            
            try
            {
                switch (Get-PSFConfigValue -FullName 'EDiscoveryTools.Search.Config.Type')
                {
                    'Json' { Import-JsonConfig -Path $importPath }
                    'Xml' { Import-XmlConfig -Path $importPath }
                    default { Import-CsvConfig -Path $importPath }
                }
                $script:defaultGroupMappingDataImported = $true
            }
            catch
            {
                Stop-PSFFunction -String Import-EDisSearchTag.DefaultImport.Failed -StringValues $importPath -EnableException $EnableException -Cmdlet $PSCmdlet -ErrorRecord $_
                return
            }
        }
    }
}

function New-EDisCase
{
<#
    .SYNOPSIS
        Creates a new eDiscovery case.
     
    .DESCRIPTION
        Creates a new eDiscovery case.
        Provides a streamlined user experience with simplified search creation over the default command.
     
    .PARAMETER Name
        The name of the case to create.
     
    .PARAMETER CaseID
        The external case identifying ID.
     
    .PARAMETER SearchName
        The name of the search to create.
        If this parameter is omitted, no search will be created.
     
    .PARAMETER SearchTag
        Any search tags to apply.
        Tags are a simplified way to limit searches by distribution group members.
        See description of Register-EDisSearchTag for details.
     
    .PARAMETER CaseType
        Whether this is a basic eDiscovery case, or an advanced eDiscovery case.
        Note: Only basic cases support having searches created for them.
     
    .PARAMETER EnableException
        This parameters disables user-friendly warnings and enables the throwing of exceptions.
        This is less user friendly, but allows catching exceptions in calling scripts.
     
    .PARAMETER Confirm
        If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
     
    .PARAMETER WhatIf
        If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
     
    .EXAMPLE
        PS C:\> New-EDisCase -Name 'Fabrikam vs. Contoso' -CaseID '1234567' -SearchName 'CourtExport' -Searchtag NorthAmerica, SouthAmerica, Emea
     
        Creates the new case "Fabrikam vs. Contoso" for the case id 1234567
        Also creates an associated search named 'CourtExport' and constrains the search to the groups behind the specified labels.
#>

    [CmdletBinding(SupportsShouldProcess = $true)]
    param (
        [Parameter(Mandatory = $true, Position = 0)]
        [string]
        $Name,
        
        [Parameter(Mandatory = $true, Position = 0)]
        [string]
        $CaseID,
        
        [string]
        $SearchName,
        
        [string[]]
        $SearchTag,
        
        [ValidateSet('Basic', 'Advanced')]
        [string]
        $CaseType = 'Basic',
        
        [switch]
        $EnableException
    )
    
    begin
    {
        Assert-Connection
        $paramsCase = @{
            Name       = $Name
            ExternalID = $CaseID
            CaseType   = 'eDiscovery'
        }
        if ($CaseType -eq 'Advanced') { $paramsCase['CaseType'] = 'AdvancedEdiscovery' }
        
        $paramsSearch = @{
            Name            = $SearchName
            Case            = $Name
            EnableException = $EnableException
        }
        if ($SearchTag) { $paramsSearch['SearchTag'] = $SearchTag }
    }
    process
    {
        Invoke-PSFProtectedCommand -ActionString 'New-EDisCase.Case.Create' -Target $Name -ScriptBlock {
            $null = New-ComplianceCase @paramsCase -ErrorAction Stop
        } -EnableException $EnableException -PSCmdlet $PSCmdlet
        if (Test-PSFFunctionInterrupt) { return }
        
        if ($SearchName)
        {
            if ($CaseType -eq 'Advanced')
            {
                Stop-PSFFunction -String 'New-EDisCase.AdvancedSearch.NotSupported' -EnableException $EnableException -Target $Name -Cmdlet $PSCmdlet
                return
            }
            try { $null = New-EDisSearch @paramsSearch }
            catch { throw }
        }
    }
}

function New-EDisSearch
{
<#
    .SYNOPSIS
        Creates a new eDiscovery Search.
     
    .DESCRIPTION
        Creates a new eDiscovery Search.
     
    .PARAMETER Name
        The name of the search to create.
     
    .PARAMETER Case
        The case to which to attach the search.
        Only basic eDiscovery cases are supported at the moment.
     
    .PARAMETER Description
        The description to add to the search.
     
    .PARAMETER SearchTag
        Any search tags to include in the search.
        Search tags apply distribution group based filters to the search.
        See description of Register-EDisSearch for details.
     
    .PARAMETER EnableException
        This parameters disables user-friendly warnings and enables the throwing of exceptions.
        This is less user friendly, but allows catching exceptions in calling scripts.
     
    .PARAMETER Confirm
        If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
     
    .PARAMETER WhatIf
        If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
     
    .EXAMPLE
        PS C:\> New-EDisSearch -Name newSearch -Case LatestCase
     
        Creates an unfiltered search against the case "LatestCase".
     
    .EXAMPLE
        PS C:\> New-ADisSearch -Name CourtExport -Case "Fabrikam vs. Contoso" -SearchTag NorthAmerica, SouthAmerica, Emea
     
        Creates a new search named CourtExport for the case "Fabrikam vs. Contoso"
        It then applies a distribution group based filter from the specified tags.
        Note: The tags and their DG mapping must first have been registered/imported.
#>

    [CmdletBinding(SupportsShouldProcess = $true)]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $Name,
        
        [Parameter(Mandatory = $true)]
        [string]
        $Case,
        
        [string]
        $Description,
        
        [string[]]
        $SearchTag,
        
        [switch]
        $EnableException
    )
    
    begin
    {
        Assert-Connection
    }
    process
    {
        $params = $PSBoundParameters | ConvertTo-PSFHashtable -Include Name, Case, Description
        if ($SearchTag)
        {
            $groups = foreach ($tag in $SearchTag)
            {
                if (-not $script:searchGroupMappingData[$tag])
                {
                    Stop-PSFFunction -String 'New-EDisSearch.Tag.Invalid' -StringValues $tag -EnableException $EnableException -Cmdlet $PSCmdlet -Continue
                }
                $script:searchGroupMappingData[$tag]
            }
            $groupsUnique = $groups | Select-Object -Unique
            $params['ExchangeLocation'] = $groupsUnique
        }
        #Invoke-PSFProtectedCommand -ActionString 'New-EDisSearch.Execute' -ActionStringValues $Case -Target $Name -ScriptBlock {
            New-ComplianceSearch @params -ErrorAction Stop
        #} -EnableException $EnableException -PSCmdlet $PSCmdlet
    }
}

function Register-EDisSearchTag
{
<#
    .SYNOPSIS
        Registers the path to a mappings file containing the mapping for simplified search creation.
     
    .DESCRIPTION
        Registers the path to a mappings file containing the mapping for simplified search creation.
     
        During New-EDisCase, the tags specified in the configuration file will be offered as tab completion.
        The group addresses registered behind it will be used for scoping the search filter.
     
        Supported formats:
        CSV: A two column table: Tag | Group
              To assign multible groups to the same tag, add multiple entries for the same tag.
              The csv should be delimited by a comma.
        Json: The Json file should be one hashtable, using the Key as Key and a list of group email addresses as values.
        XML: The XML file should be structured thus:
        <entries>
          <entry>
            <tag>ExampleName</tag>
            <group>example@domain.com</group>
          </entry>
          <entry>
            <tag>ExampleName2</tag>
            <group>example2@domain.com</group>
          </entry>
        </entries>
        Multiple groups mapped to the same tag get multiple entries anyway, similar to the csv type.
     
        All input files are expected to be UTF8 with or without BOM.
     
    .PARAMETER Path
        Path to the file to be registered.
     
    .PARAMETER Type
        Type of the input file to be registered
     
    .EXAMPLE
        PS C:\> Register-EDisSearchTag -Path '\\server\share\EDiscoverySearchMapping.csv'
     
        Registers the EDiscoverySearchMapping.csv file as input file for label mapping.
#>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [PsfValidateScript('EDiscovery.Validate.Path', ErrorString = 'EDiscovery.Validate.Path.Failed')]
        [string]
        $Path,
        
        [ValidateSet('csv','json','xml')]
        [string]
        $Type = 'csv'
    )
    
    process
    {
        $resolvedPath = Resolve-PSFPath -Path $Path -Provider FileSystem -SingleItem
        Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Search.Config.Path' -Value $resolvedPath -PassThru | Register-PSFConfig
        Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Search.Config.Type' -Value $Type -PassThru | Register-PSFConfig
    }
}

<#
This is an example configuration file
 
By default, it is enough to have a single one of them,
however if you have enough configuration settings to justify having multiple copies of it,
feel totally free to split them into multiple files.
#>


<#
# Example Configuration
Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Example.Setting' -Value 10 -Initialize -Validation 'integer' -Handler { } -Description "Example configuration setting. Your module can then use the setting using 'Get-PSFConfigValue'"
#>


Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Import.DoDotSource' -Value $false -Initialize -Validation 'bool' -Description "Whether the module files should be dotsourced on import. By default, the files of this module are read as string value and invoked, which is faster but worse on debugging."
Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Import.IndividualFiles' -Value $false -Initialize -Validation 'bool' -Description "Whether the module files should be imported individually. During the module build, all module code is compiled into few files, which are imported instead by default. Loading the compiled versions is faster, using the individual files is easier for debugging and testing out adjustments."

Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Connection.Uri' -Value 'https://ps.compliance.protection.outlook.com/powershell-liveid/' -Initialize -Validation string -Description 'The Url used to connect to the EDiscovery service in the 0365 Compliance Center'

Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Search.Config.Path' -Value '' -Initialize -Validation 'string' -Description 'Path to where the mapping file can be found, mapping selected strings/labels to distribution groups. This is used for creating search filters using userfriendly labels.'
Set-PSFConfig -Module 'EDiscoveryTools' -Name 'Search.Config.Type' -Value 'csv' -Initialize -Validation 'string' -Description 'The format of the mapping file to ingest for search acceleration.'


Set-PSFScriptblock -Name 'EDiscovery.Validate.Path' -Scriptblock {
    try { Resolve-PSFPath -Path $_ -Provider FileSystem -SingleItem }
    catch { $false }
}

<#
Stored scriptblocks are available in [PsfValidateScript()] attributes.
This makes it easier to centrally provide the same scriptblock multiple times,
without having to maintain it in separate locations.
 
It also prevents lengthy validation scriptblocks from making your parameter block
hard to read.
 
Set-PSFScriptblock -Name 'EDiscoveryTools.ScriptBlockName' -Scriptblock {
     
}
#>


Register-PSFTeppScriptblock -Name 'Compliance.Case.Name' -ScriptBlock {
    if ($fakeBoundParameters.CaseType)
    {
        (Get-ComplianceCase -CaseType $fakeBoundParameters.CaseType).Name
    }
    else { (Get-ComplianceCase).Name }
}
Register-PSFTeppArgumentCompleter -Command Get-ComplianceCase -Parameter Identity -Name 'Compliance.Case.Name'
Register-PSFTeppArgumentCompleter -Command New-EDisSearch -Parameter Case -Name 'Compliance.Case.Name'

Register-PSFTeppScriptblock -Name 'Compliance.Case.Type' -ScriptBlock {
    'eDiscovery', 'DSR', 'ComplianceWorkspace', 'AdvancedEdiscovery', 'DataInvestigation', 'InternalInvestigation', 'ComplianceClassifier', 'SupervisionPolicy', 'InsiderRisk'
}
Register-PSFTeppArgumentCompleter -Command Get-ComplianceCase -Parameter CaseType -Name 'Compliance.Case.Type'
Register-PSFTeppArgumentCompleter -Command New-ComplianceCase -Parameter CaseType -Name 'Compliance.Case.Type'


Register-PSFTeppScriptblock -Name "Compliance.Search.Tag" -ScriptBlock {
    $module = Get-Module EDiscoveryTools
    & $module { $script:searchGroupMappingData.Keys }
}
Register-PSFTeppArgumentCompleter -Command New-EDisSearch -Parameter SearchTag -Name "Compliance.Search.Tag"
Register-PSFTeppArgumentCompleter -Command New-EDisCase -Parameter SearchTag -Name "Compliance.Search.Tag"

<#
# Example:
Register-PSFTeppArgumentCompleter -Command Get-Alcohol -Parameter Type -Name EDiscoveryTools.alcohol
#>


New-PSFLicense -Product 'EDiscoveryTools' -Manufacturer 'Friedrich Weinmann' -ProductVersion $script:ModuleVersion -ProductType Module -Name MIT -Version "1.0.0.0" -Date (Get-Date "2019-11-25") -Text @"
Copyright (c) 2019 Friedrich Weinmann
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"@


# Whether a Compliance Center connection has been established.
$script:connected = $false

# Whether the default configuration set for search filter creation has been imported yet
$script:defaultGroupMappingDataImported = $false

# Used for filtering searches in a convenient manner when creating cases
$script:searchGroupMappingData = @{ }
#endregion Load compiled code