How to monitor Cisco Unified Communications Manager backups with PowerShell

This guide explains how to manage Cisco Unified Communication System (version 11.5.x), with PowerShell. Retrieving backup status is the concrete example:

  • CallManager
  • Instant Messaging & Presence (IM & P)
  • Call Center Express (CCX)
  • Cisco Unity Connection (CUC)
  • Telepresence Management Suite (TMS)

Except for ‘TMS’ all are configured to store backups on a Network Directory:
UC Backup Setting

The backup jobs create several *.tar files; here just for the ‘UCM’ component:
UC Backups in Explorer

CISCO is provides the Platform Administrative Web Services as interface to communicate with their system.

The API reference explores that the backup status is available through the ‘Maintenance Service’.
A SOAP envelope* needs to be formulated to get the information.

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="server_url">
    <soap:Header/>
    <soap:Body>
        <ser:getBackupProgress xmlns:ns="server_url"/>
    </soap:Body>
</soap:Envelope>

The lines above are only a part of required code. Missing is the correct web addressing.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.api.platform.vos.cisco.com">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:Action>urn:getAPIVersion</wsa:Action>
      <wsa:ReplyTo>
         <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
      </wsa:ReplyTo>
      <wsa:MessageID>uuid:26634481-3273-4a70-b537-ab4b874e4d6b</wsa:MessageID>    
      <wsa:To/>  
   </soapenv:Header>
   <soapenv:Body>
      <ser:getAPIVersion/>
   </soapenv:Body>
</soapenv:Envelope>

The final envelope looks like this:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://services.api.platform.vos.cisco.com">  
  <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">  
    <wsa:Action>urn:getBackupProgress</wsa:Action>  
    <wsa:ReplyTo>  
      <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>  
    </wsa:ReplyTo>  
    <wsa:MessageID>uuid:dc75e529-34fb-4009-b594-d801ec86f39e</wsa:MessageID>  
  </soap:Header>  
  <soap:Body>  
    <ser:getBackupProgress/>  
  </soap:Body>  
</soap:Envelope>

PowerShell offers the Invoke-Webrequest cmdlet to pass SOAP envelopes to a Web-Service.
Important here is to formulate the correct header.  The following works:

"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($ciscoUser+":"+$ciscoPwd))

The complete code to get the backup status :

$serverURL = 'https://srvauc521/platform-services/services/MaintenanceService?wsdl'

$soapRequest = [xml]@"
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://services.api.platform.vos.cisco.com">  
  <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">  
    <wsa:Action>urn:getBackupProgress</wsa:Action>  
    <wsa:ReplyTo>  
      <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>  
    </wsa:ReplyTo>  
    <wsa:MessageID>uuid:dc75e529-34fb-4009-b594-d801ec86f39e</wsa:MessageID>  
  </soap:Header>  
  <soap:Body>  
    <ser:getBackupProgress/>  
  </soap:Body>  
</soap:Envelope>  
"@

$header = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($ciscoUser+":"+$ciscoPwd))}

 
   $result = Invoke-WebRequest -Uri $serverURL -Headers $header -Method:Post -Body $soapRequest -ContentType "application/soap+xml" -usebasicparsing
  
  [xml]$SOAP = $result.Content 
  $xmlResult = $SOAP.Envelope.Body.getBackupProgressResponse.return.backupProgressResult.componentList

The content of $xmlResult variable is a plain text array which can be easily further processed

CDR_CAR   SRVVAUC520   CAR   SUCCESS   Tue Aug 22 01:03:08 CEST 2017   activelog/platform/drf/log/2017-08-22-01-00-06_b_SRVvauc520_cdr_car_car.log
 UCM   SRVVAUC520   PLATFORM   SUCCESS   Tue Aug 22 01:04:52 CEST 2017   activelog/platform/drf/log/2017-08-22-01-00-06_b_SRVvauc520_ucm_platform.log
 UCM   SRVVAUC520   CLM   SUCCESS   Tue Aug 22 01:04:54 CEST 2017   activelog/platform/drf/log/2017-08-22-01-00-06_b_SRVvauc520_ucm_clm.log
 …

Worth to note is that the backup status overall can be queried separately via:

$backupOverallStatus = $SOAP.Envelope.Body.getBackupProgressResponse.return.backupProgressResult.status
if ($backupOverallStatus -notmatch 'SUCCESS') {
  	$foo = ‘send success mail for instance …’
}

You can learn more about SOAP here.

Subscribe to 4sysops newsletter!

More about Cisco's PAWS there

Discussion (3)

  1. Ruben thanks a lot for posting in the wiki! The text looks great. I just made some minor edits.  I changed the introduction a little because a wiki is supposed to be collaboration platform where multiple authors contribute to a document. This is also the reason why I changed the access setting to "logged-in users can edit."

    You can review my changes in the history tab.

    You received 400 Member Points for creating this wiki doc.

Leave a Reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account