CUCMSidecarWorkflow/Private/Update-Sidecar.ps1

function Update-Sidecar
{
    <#
    .SYNOPSIS
    Updates a Cisco sidecar from a XML file.
 
    .DESCRIPTION
    The Update-Sidecar function takes a sorted XML file, creates a SOAP request to CUCM's AXL API. This function is run
 
    .PARAMETER SortedXML
       
 
    .PARAMETER DeviceName
#>


    [CmdletBinding()]
    Param
    (
        
        [xml]$SortedXML,
        [string]$DeviceName
    )

    BEGIN{}

    PROCESS
    {
        $CUCMServer = "InstanceOfCUCMServer" #TODO: Add your CUCM instance.
        $SortedFile = "C:\users\$ENV:USERNAME\desktop\Sorted.xml"
        [xml]$UpdeateRequestXML = (Get-Content $SortedFile)
        $BLFRequestXML = $UpdeateRequestXML.OuterXml #Grabs the XML from the document for use in the SOAP Request.

    #Creating SOAP Request to add sorted xml to sidecar (Either after removing or adding a user)
 [xml]$UpdateRequest = @"
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns='http://www.cisco.com/AXL/API/10.0'>
<soapenv:Body>
    <ns:updateDeviceProfile sequence="?">
        <name>$deviceName</name>
        $BLFRequestXML
    </ns:updateDeviceProfile>
</soapenv:Body>
</soapenv:Envelope>
"@


        $headers= @{
            'Content-Type'='text\xml;charset=UTF-8';
            'SOAPAction'='CUCM:DB ver 11.0';
        }
        
            Invoke-RestMethod -Method Post -Uri "https://$CUCMServer`:8443/axl/" -Headers $headers -Body $UpdateRequest -Credential $cred  -ErrorAction Stop| Out-Null
    
        
    } #PROCESS

    END{}
}