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.

Purpose

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 $_.name | Export-Clixml “$_.xml”}

Export specific set of cmdlets –Get-Command get-cs*voice*| foreach {invoke-expression $_.name | 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 (($i.name -eq “Get-CsAdminRoleAssignment”) -or ($i.name -eq “Get-CsClientCertificate”) -or ($i.name -eq “Get-CsClientPinInfo”) -or ($i.name -eq “Get-CsRgsConfiguration”) -or ($i.name -eq “Get-CsUserPoolInfo”) -or ($i.name -eq “Get-CsBackupServiceStatus”) -or ($i.name -eq “Get-CsClientAccessLicense”) -or ($i.name -eq “Get-CsDatabaseMirrorState”) -or ($i.name -eq “Get-CsEffectivePolicy”) -or ($i.name -eq “Get-CsPersistentChatEligiblePrincipal”) -or ($i.name -eq “Get-CsPoolBackupRelationship”) -or ($i.name -eq “Get-CsPoolFabricState”) -or ($i.name -eq “Get-CsTestUserCredential”) -or ($i.name -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:

Limitations

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 “*sip.allthingsuc.co.uk*”}

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.

Disclaimer

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