PSCUCM.psm1

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

# Detect whether at some level dotsourcing was enforced
$script:doDotSource = Get-PSFConfigValue -FullName PSCUCM.Import.DoDotSource -Fallback $false
if ($PSCUCM_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 PSCUCM.Import.IndividualFiles -Fallback $false
if ($PSCUCM_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
    )
    
    if ($doDotSource) { . (Resolve-Path $Path) }
    else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path $Path)))), $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
Function ConvertTo-XMLString
{
<#
.SYNOPSIS
    Outputs a human readable simple text XML representation of a simple PS object.
.DESCRIPTION
    Outputs a human readable simple text XML representation of a simple PS object.
.PARAMETER InputObject
    The input object to inspect and dump.
.PARAMETER ObjectName
    The name of the root element in the document. Defaults to "Object"
.PARAMETER ExcludeProperty
    Optional. Property(s) to exclude from output
.PARAMETER RootAttributes
    Optional. Attributes to put on root element
.PARAMETER BooleanValuesAsLowercase
    Optional. Print boolean values as lowercase instead of propercase (true vs True)
.PARAMETER DateFormat
    Optional. DateFormat string to use for datetime properties
.PARAMETER IndentLevel
    Internal use, this is a recursive function
.PARAMETER Root
    Internal use, this is a recursive function
.EXAMPLE
    Something, somelthing
 
    Does something
.NOTES
    Provided by Ish__ in PowerShell Discord (https://pwsh.ca/discord): https://gist.github.com/charlieschmidt/57292a97a3a8760e4baaffba425e5010
#>

    [cmdletbinding()]
    param (
        [parameter(Mandatory=$true,valuefrompipeline=$true)]
        [object]$InputObject,
        [Parameter(Mandatory=$false)]
        [String]$ObjectName = "Object",
        [Parameter(Mandatory=$false)]
        [string[]]$ExcludeProperty,
        [Parameter(Mandatory=$false)]
        [hashtable]$RootAttributes,
        [Parameter(Mandatory=$false)]
        [switch]$BooleanValuesAsLowercase,
        [Parameter(Mandatory=$false)]
        [string]$DateFormat = "",
        [Parameter(Mandatory=$false)]
        [Int32]$IndentLevel = 1,
        [Parameter(Mandatory=$false)]
        [boolean]$Root = $true
    )
    begin
    {
        $OutputStrings = New-Object System.Collections.Generic.List[System.String]
    }
    process
    {
        $IndentString = ("`t" * $IndentLevel)

        # Output the root element opening tag
        if ($Root)
        {
            $RootElement = $ObjectName

            if ($RootAttributes)
            {
                foreach ($Key in $RootAttributes.Keys)
                {
                    $RootElement += " {0}=`"{1}`"" -f $Key, $RootAttributes[$Key]
                }
            }
            $OutputStrings.Add("<$RootElement>")
        }

        # Iterate through all of the note properties in the object.
        $Properties = @()
        if ($InputObject.GetType().Name -eq "Hashtable" -or $InputObject.GetType().Name -eq "OrderedDictionary")
        {
            $Properties = $InputObject.Keys
        }
        elseif ($InputObject.GetType().Name -eq "PSCustomObject")
        {
            $Properties = Get-Member -InputObject $InputObject -MemberType NoteProperty | Select-Object -Expand Name
        }
        elseif ($InputObject.GetType().Name -eq "Boolean" -and $BooleanValuesAsLowerCase.IsPresent)
        {
            $PropertyValueString = ([string]$InputObject).ToLower()
        }
        elseif ($InputObject.GetType().Name -ieq "datetime")
        {
            $PropertyValueString = [string]($InputObject).ToString($DateFormat)
        }
        else
        {
            $PropertyValueString = $InputObject.ToString()
        }

        if ($Properties.Count -eq 0)
        {
            $OutputStrings.Add($PropertyValueString)
        }
        else
        {
            foreach ($Property in $Properties)
            {
                if ($ExcludeProperty -inotcontains $Property)
                {
                    $PropertyValue = $InputObject.($Property)

                    # Check if the property is an object and we want to dig into it
                    if ($null -eq $PropertyValue)
                    {
                        $OutputStrings.Add("$IndentString<$Property />")
                    }
                    elseif ($PropertyValue.GetType().Name -eq "PSCustomObject" -or $PropertyValue.gettype().name -eq "Hashtable" -or $PropertyValue.GetType().Name -eq "OrderedDictionary")
                    { # is object, so dig in, with wrapping xml tags
                        $OutputStrings.Add("$IndentString<$Property>")
                        $PropertyXml = ConvertTo-XMLString -InputObject $PropertyValue -Root $false -IndentLevel ($IndentLevel + 1) -DateFormat $DateFormat  -BooleanValuesAsLowercase:$BooleanValuesAsLowercase
                        $OutputStrings.Add($PropertyXml)
                        $OutputStrings.Add("$IndentString</$Property>")
                    }
                    elseif ($PropertyValue.GetType().Name.ToString().EndsWith("[]"))
                    { # is array, so get value for each element in array, then wrap total (if those were objects) or wrap individually (if they were strings/ints/etc)
                        $PropertyXml = @()
                        $SubObjectPropertyNames = @()
                        foreach ($APropertyValue in $PropertyValue)
                        {
                            $ValueIsObject = $false
                            if ($APropertyValue.gettype().name -eq "PSCustomObject" -or $APropertyValue.gettype().name -eq "Hashtable" -or $APropertyValue.GetType().Name -eq "OrderedDictionary")
                            {
                                switch ($APropertyValue.GetType().Name)
                                {
                                    "Hashtable" { $SubObjectPropertyNames += $APropertyValue.Keys }
                                    "OrderedDictionary" { $SubObjectPropertyNames += $APropertyValue.Keys }
                                    "PSObject" { $SubObjectPropertyNames += $APropertyValue.PSObject.Properties.Name }
                                    "PSCustomObject" { $SubObjectPropertyNames += $APropertyValue.PSObject.Properties.Name }
                                }
                                $ValueIsObject = $true
                            }

                            $PropertyXml += ConvertTo-XMLString -InputObject $APropertyValue -Root $false -DateFormat $DateFormat -BooleanValuesAsLowercase:$BooleanValuesAsLowercase -IndentLevel ($IndentLevel + 1)
                        }

                        $ValueIsWrapper = $false
                        if ($ValueIsObject)
                        {
                            $Ps = ($SubObjectPropertyNames | Select-Object -Unique).Count
                            if ($PS -eq 1)
                            {
                                $ValueIsWrapper = $true
                            }
                        }
                        if ($PropertyXml.Count -ne 0)
                        {
                            if ($ValueIsObject)
                            {
                                if ($ValueIsWrapper)
                                {
                                    $OutputStrings.Add("$IndentString<$Property>")
                                    $PropertyXmlString = $PropertyXml -join "`n"
                                    $OutputStrings.Add($PropertyXmlString)
                                    $OutputStrings.Add("$IndentString</$Property>")
                                }
                                else
                                {
                                    $OutputStrings.Add("$IndentString<$Property>")
                                    $PropertyXmlString = $PropertyXml -join "`n$IndentString</$Property>`n$IndentString<$Property>`n"
                                    $OutputStrings.Add($PropertyXmlString)
                                    $OutputStrings.Add("$IndentString</$Property>")
                                }
                            }
                            else
                            {
                                foreach ($PropertyXmlString in $PropertyXml)
                                {
                                    $OutputStrings.Add("$IndentString<$Property>$PropertyXmlString</$Property>")
                                }
                            }
                        }
                        else
                        {
                            $OutputStrings.Add("$IndentString<$Property />")
                        }
                    }
                    else
                    { # else plain old property
                        $PropertyXml = ConvertTo-XMLString -InputObject $PropertyValue -Root $false -DateFormat $DateFormat -BooleanValuesAsLowercase:$BooleanValuesAsLowercase -IndentLevel ($IndentLevel + 1)
                        $OutputStrings.Add("$IndentString<$Property>$PropertyXml</$Property>")
                    }
                }
            }
        }

        # Output the root element closing tag
        if ($Root)
        {
            $OutputStrings.Add("</$ObjectName>")
        }
    }

    End
    {
        $OutputStrings.ToArray() -join "`n"
    }
}


function Get-PSCUCMPhoneName {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $DN,
        [switch]
        $EnableException
    )
    $CucmAxlSplat = @{
        SqlQuery        = @'
            SELECT device.name
            FROM
            device, numplan, devicenumplanmap
            WHERE
            devicenumplanmap.fkdevice = device.pkid
            AND
            devicenumplanmap.fknumplan = numplan.pkid
            AND
            numplan.dnorpattern = "{0}"
'@
 -f $DN
        EnableException = $EnableException
    }
    Invoke-PSCUCMSqlQuery @CucmAxlSplat
}

function Add-PSCUCMPhone {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $Name,
        [Parameter(Mandatory = $true)]
        [Alias('Model')]
        [string]
        $Product,
        [Parameter(Mandatory=$true)]
        [string]
        $DevicePoolName,
        [Parameter(Mandatory = $true)]
        [string]
        $Protocol,
        [Parameter()]
        [string]
        $Description,
        [Parameter()]
        [switch]
        $EnableException,
        [Parameter()]
        [switch]
        $OutputXml
    )

    <#
         <phone>
            <name>SEP000000000000</name>
            <description>Optional</description>
            <product>?</product>
            <class>?</class>
            <protocol>?</protocol>
            <protocolSide>User</protocolSide>
            <devicePoolName uuid="?">?</devicePoolName>
         </phone>
    #>

        
    $class = 'Phone'
    
    $CucmAxlSplat = @{
        entity          = 'addPhone'
        parameters      = @{
            phone = @{
                name                  = $MacAddress
                product               = $Product
                class                 = $class
                protocol              = $Protocol
                protocolSide          = $protocolSide
                devicePoolName        = $devicePoolName
                commonPhoneConfigName = $commonPhoneConfigName
                locationName          = $locationName
                useTrustedRelayPoint  = $useTrustedRelayPoint
                phoneTemplateName     = $Template
                primaryPhoneName      = $primaryPhoneName
                deviceMobilityMode    = $deviceMobilityMode
                certificateOperation  = $certificateOperation
                packetCaptureMode     = $packetCaptureMode
                builtInBridgeStatus   = $builtInBridgeStatus
                description           = $Description
            }
        }
        OutputXml       = $OutputXml
        EnableException = $EnableException
    }
    Invoke-PSCUCMAxlQuery @CucmAxlSplat
    
}


function Get-PSCUCMPhone {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $DN,
        [switch]
        $EnableException
    )
    $phoneNameByDNSplat = @{
        DN              = $DN
        EnableException = $EnableException
    }
    $phoneName = Get-PSCUCMPhoneName @phoneNameByDNSplat |
        Select-Xml -XPath '//name' |
        Select-Object -ExpandProperty node |
        Select-Object -ExpandProperty '#text'
    $CucmAxlSplat = @{
        'entity'     = 'getPhone'
        'parameters' = @{
            'name' = $phoneName
        }
    }
    Invoke-PSCUCMAxlQuery @CucmAxlSplat | Select-Xml -XPath '//phone' | Select-Object -ExpandProperty node
}

function Get-PSCUCMPhoneServices {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = "CUCM returns to us all of the services. We can't pick and choose which ones to return.")]
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $DN,
        [switch]
        $EnableException
    )
    $PhoneByDNSplat = @{
        DN              = $DN
        EnableException = $EnableException
    }
    Get-PSCUCMPhone @PhoneByDNSplat |
        Select-Xml -XPath '//service' |
        Select-Object -ExpandProperty node
}

function Get-PSCUCMTranslationPattern {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $TranslationPattern,
        [string]
        $RoutePartitionName,
        [switch]
        $EnableException
    )
    $invokeCucmAxlSplat = @{
        entity          = 'getTransPattern'
        parameters      = @{
            pattern            = $TranslationPattern
            routePartitionName = $RoutePartitionName
        }
        EnableException = $EnableException
    }
    Invoke-PSCUCMAxlQuery @invokeCucmAxlSplat
}

function Set-PSCUCMTranslationPattern {
    [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $TranslationPattern,
        [string]
        $RoutePartitionName = $null,
        [string]
        $CalledPartyTransformationMask = $null,
        [switch]
        $EnableException
    )
    $invokeCucmAxlSplat = @{
        entity          = 'updateTransPattern'
        parameters      = @{
            pattern = $TranslationPattern
        }
        EnableException = $EnableException
    }
    if ($RoutePartitionName) {
        $invokeCucmAxlSplat.parameters.routePartitionName = $RoutePartitionName
    }
    if ($calledPartyTransformationMask) {
        $invokeCucmAxlSplat.parameters.calledPartyTransformationMask = $calledPartyTransformationMask
    }
    if ($PSCmdlet.ShouldProcess($server, "Set Translation Pattern $TranslationPattern")) {
        Invoke-PSCUCMAxlQuery @invokeCucmAxlSplat
    }
}

function Invoke-PSCUCMLdapSync {
    <#
    .SYNOPSIS
    Invoke sync of LDAP Directory
     
    .DESCRIPTION
    Invoke sync of LDAP Directory
     
    .PARAMETER LdapDirectory
    LDAP Directory to sync
     
    .PARAMETER cancelActive
    Cancel active sync
     
    .PARAMETER AXLVersion
    AXL Version for Server.
     
    .PARAMETER server
    Server to query
     
    .PARAMETER Credential
    Credential to use for API access
     
    .PARAMETER EnableException
    Replaces user friendly yellow warnings with bloody red exceptions of doom!
    Use this if you want the function to throw terminating errors you want to catch.
 
    .PARAMETER WhatIf
    What If?
     
    .PARAMETER Confirm
    Confirm...
     
    .EXAMPLE
    An example
 
    System Up Time: 0d, 0h, 13m
    #>

    
    [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium")]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $LdapDirectory,
        [switch]
        $CancelActive,
        [switch]
        $EnableException
    )
    $invokeCucmAxlSplat = @{
        entity     = 'doLdapSync'
        parameters = @{
            name = $LdapDirectory
            sync = $true
        }
        EnableException = $EnableException
    }
    if ($cancelActive.IsPresent) {
        $invokeCucmAxlSplat.parameters.sync = $false
    }
    if ($PSCmdlet.ShouldProcess($server, "Set Translation Pattern $TranslationPattern")) {
        Invoke-PSCUCMAxlQuery @invokeCucmAxlSplat
    }
}

function Connect-PSCucm {

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $AXLVersion,
        [Parameter(Mandatory = $true)]
        [string]
        $server,
        [Parameter(Mandatory = $true)]
        [pscredential]
        $Credential,
        [switch]
        $EnableException,
        [switch]
        $SkipCertificateCheck,
        [switch]
        $PersistSettings
    )
    Set-PSFConfig -Module PSCUCM -Name Connected -Value $true
    Set-PSFConfig -Module PSCUCM -Name AXLVersion -Value $AXLVersion
    Set-PSFConfig -Module PSCUCM -Name Server -Value $Server
    Set-PSFConfig -Module PSCUCM -Name Credential -Value $Credential
    Set-PSFConfig -Module PSCUCM -Name SkipCertificateCheck -Value $SkipCertificateCheck
    $Global:PSDefaultParameterValues['*-PSCucm*:EnableException'] = $EnableException
    if ($PersistSettings) {
        Register-PSFConfig -FullName pscucm.axlversion
        Register-PSFConfig -FullName pscucm.server
        Register-PSFConfig -FullName pscucm.credential
        Register-PSFConfig -FullName pscucm.$SkipCertificateCheck
    }
}

function Disconnect-PSCucm {
    <#
    .SYNOPSIS
    "Disconnect" from CUCM Server
     
    .DESCRIPTION
    "Disconnect" from CUCM Server
     
    .EXAMPLE
    Disconnect-PSCucm
 
    Disconnects from CUCM Server.
     
    .NOTES
    General notes
    #>

    
    [CmdletBinding()]
    param (
    )
    Reset-PSFConfig -Module pscucm
    $Global:PSDefaultParameterValues.remove('*-PSCucm*:EnableException')
}

function Invoke-PSCUCMAxlQuery {
    
    [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Low")]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $Entity,
        [Parameter(Mandatory = $true)]
        [hashtable]
        $Parameters,
        [switch]
        $EnableException,
        [switch]
        $OutputXml
    )
    $AXLVersion = Get-PSFConfigValue -FullName pscucm.axlversion
    if (-not $OutputXml) {
        $EnableException = $EnableException -or $(Get-PSFConfigValue -FullName pscucm.enableexception)
        if (-not (Get-PSFConfigValue -FullName pscucm.connected)) {
            Stop-PSFFunction -Message "Unable to process AXL request. Not connected." -EnableException $EnableException
        }
        $Server = Get-PSFConfigValue -FullName pscucm.server
        $Credential = Get-PSFConfigValue -FullName pscucm.credential
    }
    $object = @{
        'soapenv:Header' = ''
        'soapenv:Body' = @{
            "ns:$entity" = $Parameters
        }
    }
    $body = ConvertTo-XMLString -InputObject $object -ObjectName "soapenv:Envelope" -RootAttributes @{"xmlns:soapenv"="http://schemas.xmlsoap.org/soap/envelope/"; "xmlns:ns"="http://www.cisco.com/AXL/API/$AXLVersion"}
    if (-not $OutputXml) {
        if ($PSCmdlet.ShouldProcess($Server, "Execute AXL query $Entity")) {
        
            $CUCMURL = "https://$Server/axl/"
            $headers = @{
                'Content-Type' = 'text/xml; charset=utf-8'
            }
            $IRMParams = @{
                Headers    = $headers
                Body       = $body
                Uri        = $CUCMURL
                Method     = 'Post'
                Credential = $Credential
            }
            if (Get-PSFConfigValue -FullName pscucm.skipcertificatecheck) {
                if ($PSVersionTable.PSVersion.Major -ge 6) {
                    $IRMParams.SkipCertificateCheck = $true
                }
                else {
                    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
                }
            }
            try {
                Invoke-WebRequest @IRMParams |
                    Select-XML -XPath '//return' |
                    Select-Object -ExpandProperty Node
            }
            catch {
                $ErrorMessage = $_.ErrorDetails.message
                $PSFMessage = "Failed to execute AXL entity $Entity."
                if (($null -ne $ErrorMessage) -and ($_.Exception.Response.StatusCode -eq 'InternalServerError')) {
                    if ($PSVersionTable.PSVersion.Major -ge 6) {
                        $null = $ErrorMessage -match "(\d+)(.*)$Entity"
                        $axlcode = $Matches[1]
                        $axlMessage = $Matches[2]
                    }
                    else {
                        $axlcode = ($ErrorMessage | select-xml -XPath '//axlcode' | Select-Object -ExpandProperty Node).'#text'
                        $axlMessage = ($ErrorMessage | select-xml -XPath '//axlmessage' | Select-Object -ExpandProperty Node).'#text'
                    }
                    $PSFMessage += " AXL Error: $axlMessage ($axlcode)"
                }
                Stop-PSFFunction -Message $PSFMessage -ErrorRecord $_ -EnableException $EnableException
                return
            }
        }
    }
    else {
        $body
    }
}


function Invoke-PSCUCMSqlQuery {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $SqlQuery,
        [switch]
        $EnableException,
        [switch]
        $OutputXml
    )
    $CucmAxlSplat = @{
        entity          = 'executeSQLQuery'
        parameters      = @{
            sql = $SqlQuery
        }
        EnableException = $EnableException
        OutputXml       = $OutputXml
    }
    Invoke-PSCUCMAxlQuery @CucmAxlSplat
}

<#
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 'PSCUCM' -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 'PSCUCM' -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 'PSCUCM' -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 'PSCUCM' -Name 'Connected' -Value $false -Description 'Flag that we''ve "connected" to the server' -Initialize
Set-PSFConfig -Module 'PSCUCM' -Name 'AXLVersion' -Value $null -Description "AXL Version used by the server (typically the same version as CUCM" -Initialize
Set-PSFConfig -Module 'PSCUCM' -Name 'Server' -Value $null -Description "Server for PSCUCM to connect to." -Initialize
Set-PSFConfig -Module 'PSCUCM' -Name 'Credential' -Value $null -Description "Credential for PSCUCM to use to connect to the server." -Initialize
Set-PSFConfig -Module 'PSCUCM' -Name 'SkipCertificateCheck' -Value $null -Description "Should PSCUCM Skip the certificate check (If you use a self signed you want to set this)" -Initialize

<#
# Example:
Register-PSFTeppScriptblock -Name "PSCUCM.alcohol" -ScriptBlock { 'Beer','Mead','Whiskey','Wine','Vodka','Rum (3y)', 'Rum (5y)', 'Rum (7y)' }
#>


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


New-PSFLicense -Product 'PSCUCM' -Manufacturer 'corbob' -ProductVersion $script:ModuleVersion -ProductType Module -Name MIT -Version "1.0.0.0" -Date (Get-Date "2018-12-30") -Text @"
Copyright (c) 2018 corbob
 
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.
"@

#endregion Load compiled code