#Lync Question 32: How do I dump Lync configuration to text files

Reblog of an old post of mine

When documenting a Lync deployment this PowerShell has been invaluable as I can easily convert the output by copy and pasting into Microsoft Word and then select the content use the Insert Table -> Convert Text to Table and select the Separate text at Other and enter a colon :

Then with minimal effort, I can document the key policies and configuration.

Here is a nice PowerShell one-liner which will dump all the output of the Get-Cs cmdlets to text files. It works with both Lync Server 2010 and 2013.

Just open the Lync Server Management Shell create a new empty directory and change directory into it and run the cmdlet

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 | out-file $i".txt"}}}

And for Skype for Business here

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-CsPowerShellEndPoint") -or ($i.name -eq "Get-CsTestUserCredential") -or ($i.name -eq "Get-CsWebTicket")-or ($i.name -eq "Get-CsPersistentChatAddin")-or ($i.name -eq "Get-CsPersistentChatCategory")-or ($i.name -eq "Get-CsUser")-or ($i.name -eq "Get-CsUserAcp")-or ($i.name -eq "Get-CsAdUser")-or ($i.name -eq "Get-csAdPrincipal")-or ($i.name -eq "Get-CsPersistentChatRoom")-or ($i.name -eq "Get-CsBusyOptions")-or ($i.name -eq "Get-CsGroupPickupUserOrbit")-or ($i.name -eq "Get-CsSlaConfiguration")){} Else {. $i.Name | ConvertTo-Html -As List | Set-Content $i".htm"}}}

Thanks to Pat Richard for the comments and the PowerShell optimisation and saving a couple bytes of command line which I ignored but was noted.

Advertisements

2 thoughts on “#Lync Question 32: How do I dump Lync configuration to text files

  1. Or
    foreach ($i in (Get-Command Get-Cs* -CommandType cmdlet | Where-Object {($_.name -ne “Get-CsAdminRoleAssignment”) -and ($_.name -ne “Get-CsClientCertificate”) -and ($_.name -ne “Get-CsClientPinInfo”) -and ($_.name -ne “Get-CsRgsConfiguration”) -and ($_.name -ne “Get-CsUserPoolInfo”) -and ($_.name -ne “Get-CsBackupServiceStatus”) -and ($_.name -ne “Get-CsClientAccessLicense”) -and ($_.name -ne “Get-CsDatabaseMirrorState”) -and ($_.name -ne “Get-CsEffectivePolicy”) -and ($_.name -ne “Get-CsPersistentChatEligiblePrincipal”) -and ($_.name -ne “Get-CsPoolBackupRelationship”) -and ($_.name -ne “Get-CsPoolFabricState”) -and ($_.name -ne “Get-CsTestUserCredential”) -and ($_.name -ne “Get-CsWebTicket”)})){
    . $i.Name -ErrorAction SilentlyContinue | Out-File $i”.txt” -force
    }

  2. Okay, was bored, and got it down even further:
    Get-Command Get-Cs* -CommandType cmdlet | Where-Object {($_.name -ne “Get-CsAdminRoleAssignment”) -and ($_.name -ne “Get-CsClientCertificate”) -and ($_.name -ne “Get-CsClientPinInfo”) -and ($_.name -ne “Get-CsRgsConfiguration”) -and ($_.name -ne “Get-CsUserPoolInfo”) -and ($_.name -ne “Get-CsBackupServiceStatus”) -and ($_.name -ne “Get-CsClientAccessLicense”) -and ($_.name -ne “Get-CsDatabaseMirrorState”) -and ($_.name -ne “Get-CsEffectivePolicy”) -and ($_.name -ne “Get-CsPersistentChatEligiblePrincipal”) -and ($_.name -ne “Get-CsPoolBackupRelationship”) -and ($_.name -ne “Get-CsPoolFabricState”) -and ($_.name -ne “Get-CsTestUserCredential”) -and ($_.name -ne “Get-CsWebTicket”)} | ForEach-Object {. $_.Name -ErrorAction SilentlyContinue | Out-File $_”.txt” -force}

    Although, depending on the environment, some of those cmdlets might be needed. But a neat concept of the one liner.

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