Scripts

SfB Backup Script Version 1

Here is a simple script to backup Skype for Business. Not fancy, but it does the job

Import-module lync

<#

The account that this runs as for a scheduled task must have permmisions to run these commands, CSAdministrator

#>

<########### Variables ##########>

$bpath = “c:\backup” #THe directory of the location to store the backups

$daystokeep = -14 #How many days worth of backups to keep

<########### End Variables ######>

#Generate Filename format

$timestamp = get-date -UFormat %Y%m%d%H%M

#Get each server type. I could do this at the actual server statement below, but may use it later as well

$appserver = (get-csservice -applicationserver).PoolFQDN

$cms = (get-csservice -CentralManagement).PoolFQDN

$confserver = (get-csservice -ConferencingServer).PoolFQDN

$Edge = (get-csservice -EdgeServer).PoolFQDN

$filestore= (get-csservice -FileStore).PoolFQDN

$management= (get-csservice -ManagementServer).PoolFQDN

$pc= (get-csservice -PersistentChatServer).PoolFQDN

#Create the directory if not present

if (!(test-path $bpath)) {new-item -ItemType directory -Path $bpath}

#Delete Old Files

get-childitem $bpath -recurse | Where-Object {$_.lastwritetime -lt ((get-date).adddays($daystokeep))} | Remove-Item -force -Recurse | out-null

#global Settings

Export-CsConfiguration -FileName “$bpath\$timestamp-cms.zip”

Export-CsLisConfiguration -FileName “$bpath\$timestamp-lis.zip”

(Get-CsTopology -AsXml).toString() | Out-File “$bpath\$timestamp-topology.tbxml”

Get-CsVoicePolicy | Export-Clixml -path “$bpath\$timestamp-voicepolicy.xml”

Get-CsVoiceRoute | Export-Clixml -Path “$bpath\$timestamp-voiceroute.xml”

Get-CsPstnUsage | Export-Clixml -Path “$bpath\$timestamp-pstnusage.xml”

Get-CsVoiceConfiguration | Export-Clixml -Path “$bpath\$timestamp-voiceconfig.xml”

Get-CsTrunkConfiguration | Export-Clixml -path “$bpath\$timestamp-trunkconfig.xml”

Get-CsUnassignedNumber | Select-Object * | Export-Csv -path “$bpath\$timestamp-unassigned.csv” -NoTypeInformation

Get-CsAnnouncement | Select-Object * | Export-Csv -path “$bpath\$timestamp-annoucement.csv” -NoTypeInformation

Get-CsCommonAreaPhone | Select-Object * | Export-Csv -path “$bpath\$timestamp-commonarea.csv” -NoTypeInformation

Get-CsAnalogDevice | Select-Object * | Export-Csv -path “$bpath\$timestamp-analogdevices.csv” -NoTypeInformation

<# To run specific commands on each server rolse. Remote management must be enabled and for edge server you will need to pass credendtials or use passthru

foreach ($host in $cms) {

invoke-command -computer $host {Export-CsConfiguration -filename “$bpath\$timestamp-cms-$host.zip”}

}

foreach ($host in $appserver) {

invoke-command -computer $host {Export-CsConfiguration -filename “$bpath\$timestamp-cms-$host.zip”}

}

foreach ($host in $appserver) {

}

foreach ($host in $appserver) {

}

foreach ($host in $appserver) {

}

foreach ($host in $appserver) {

}

foreach ($host in $appserver) {

}

#>

5 thoughts on “SfB Backup Script Version 1

  1. Comprar Viagra Sin Receta En Espana [url=http://cialibuy.com]Buy Cialis[/url] Cialis En Pharmacie Forum Cialis Y Levitra Contrareembolso Dexamethasone Fast Delivery

  2. Nice blog right here! Additionally your web site loads up very fast!
    What web host are you the use of? Can I get your associate
    hyperlink for your host? I wish my web site
    loaded up as quickly as yours lol

Leave a Reply

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