Run Lync cmdlets Offline

Being a consultant it is often required to produce detailed design and implementation documents for customers. For various reasons it is not always possible to have access to customers network whilst completing this documentation. The script below addresses this issue. It essentially allows you to grab an offline copy of the Lync environment and invoke Get-cs* cmdlets.


The script allows you to execute Lync Shell (Get-cs*) cmdlets on your local machine (which may or may not have Lync Management Shell). This is achieved by using XML files which are exported using export-clixml from Live Lync environment. The script can be downloaded here

Script Pre-requisite

The script requires access to Lync XML files generated using Lync Management Shell. The files can be generated in couple of different ways. The generated filename should have the cmdlets name prefixed to it (eg: get-csuser cmdlets filename should be get-csuser.xml).

Below are the some of the example to output necessary XML files. These cmdlets should be run on Lync Server within Lync Server Management Shell:

Export only specific cmdlet – Get-command get-cscertificate | foreach {invoke-expression $ | Export-Clixml “$_.xml”}

Export specific set of cmdlets –Get-Command get-cs*voice*| foreach {invoke-expression $ | Export-Clixml “$_.xml”}

Export all Get-CS* (with few exceptions).This can take some time depending on you configuration. The following one-liner/script (with slight modification) from Ari’s blog can be used to achieve this.

foreach($i in Get-Command Get-Cs*) { if($i.CommandType -eq “Cmdlet”){if (($ -eq “Get-CsAdminRoleAssignment”) -or ($ -eq “Get-CsClientCertificate”) -or ($ -eq “Get-CsClientPinInfo”) -or ($ -eq “Get-CsRgsConfiguration”) -or ($ -eq “Get-CsUserPoolInfo”) -or ($ -eq “Get-CsBackupServiceStatus”) -or ($ -eq “Get-CsClientAccessLicense”) -or ($ -eq “Get-CsDatabaseMirrorState”) -or ($ -eq “Get-CsEffectivePolicy”) -or ($ -eq “Get-CsPersistentChatEligiblePrincipal”) -or ($ -eq “Get-CsPoolBackupRelationship”) -or ($ -eq “Get-CsPoolFabricState”) -or ($ -eq “Get-CsTestUserCredential”) -or ($ -eq “Get-CsWebTicket”)){} Else {. $i.Name | export-clixml $i”.xml”}}}

Once you have exported the XML files, copy the files over to your local machine. You do not have to copy all the XML files if you don’t want the output of those cmdlets (eg: get-csuser, get-csuseracp, get-csuser and get-csadmin role generate large XML files which may slow down the import process)

Script Execution

On your local machine open PowerShell and launch the script. The script accepts only one parameter “folderpath”.This is the location where XML files are located. This will typically be your local machine (NOT Lync Server)

Browse to the script and enter the folder path where XML files are located

To view which cmdlets are available enter:

Get-Command get-cs* -CommandType Function

Execute a cmdlet:


As all the data is generated using XML files no inbuilt Lync Management Shell filtering is available, eg: you cannot use –filter parameter but all native PowerShell filtering can be used.

Eg: Get-CsCertificate | Where-Object {$_.AlternativeNames -like “**”}

There are few cmdlets which require some input (eg: get-csuserpoolinfo, etc) hence may fail and will not be exported until you provide the input.


As with any script please use the script at your own risk.

One Thought on “Run Lync cmdlets Offline

  1. Pingback: Run Microsoft Exchange cmdlets offline | allthingsuc

Leave a Reply

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

Solve this to prove you are not a bot * Time limit is exhausted. Please reload the CAPTCHA.

Post Navigation