Skype for Business 5 minute Admin: Exporting Archiving Data

Purpose of 5 minute Admin

To provide Skype for Business Administrators with code snippets to help with day to day administration tasks without the need to remember PowerShell commandlets and parameters.

ExportArchivingData.ps1

This script will export archiving data from SQL to a folder of your choice

##################################################################
# SCRIPT TITLE: EXPORTARCHIVINGDATA                              #
# VERSION: 1.0                                                   #
# LICENCE: FREE UNRESTRICTED                                     #
# SUPPORT: WWW.SKYPE4B.UK                                        #
# CREATOR: MARK VALE                                             #
# WARRANRY: NONE - USE AT OWN RISK                               #
# SYNOPSIS: SCRIPT TO EXPORT ARCHIVING DATA TO EML FILES FOR     #
#           INSTANT MESSAGE RECOVERY                             #                           
##################################################################
Import-Module SkypeforBusiness
$user = Read-Host "Enter user SIP Address or leave empty for all":
$startdate = Read-Host "Enter Start Date e.g. 1/9/2015:" 
$enddate = Read-Host "Enter End Date e.g 5/9/2015 or leave blank for none:" 
############################################################################
# Change Report Path if Required                                           #
############################################################################
$reportpath = "C:\SfBArchivingData\"
$archdatabase = Get-CsService -ArchivingDatabase | Select Identity
if (!(Test-Path $reportpath)){
 New-Item -ItemType Directory -Path $reportpath -Force
}
If (!($user)){
   try{
    if (!($enddate)){
        Export-CsArchivingData -Identity $archdatabase.Identity -StartDate $startdate -OutputFolder $reportpath
    }else{
        Export-CsArchivingData -Identity $archdatabase.Identity -StartDate $startdate -EndDate $enddate -OutputFolder $reportpath
    }
    }
    catch{
        write-Host -ForegroundColor Red -BackgroundColor Black "Failed to export Archiving Data $($_.ExceptionMessage)"
    }
}else{
    try{
        if (!($enddate)){
            Export-CsArchivingData -Identity $archdatabase.Identity -UserUri "sip:$($user)" -StartDate $startdate -OutputFolder $reportpath
        }else{
            Export-CsArchivingData -Identity $archdatabase.Identity -UserUri "sip:$($user)" -StartDate $startdate -EndDate $enddate -OutputFolder $reportpath
        }
        }
        catch{
            write-Host -ForegroundColor Red -BackgroundColor Black "Failed to export Archiving Data $($_.ExceptionMessage)"
        }
}

Files will be exported to .EML files which can be opened using Outlook.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s