Pages

Saturday, February 21, 2015

Powershell Scripts for Lync 2103


In this Blog we see few Power shell scripts/ Lync Management scripts for day to day Jobs

To get the Lync Enabled users.

Get-CsUser -OnLyncServer -Filter {Enabled -eq $true} | Select-Object SipAddress, SamAccountName, DisplayName, LineURI, Enabled, EnterpriseVoiceEnabled, ConferencingPolicy | Export-CSV -Path C:\Output\Lynceabled users.txt


To Add an Federated Domain using Command.

New-CsAllowedDomain -Identity "Contoso.com" -ProxyFqdn "sip.contoso.com" -MarkForMonitoring $True -Comment "you can put comments here how requested"

To get Disabled AD accounts for Lync users

Get-CsAdUser | ?{$_.UserAccountControl -match "AccountDisabled" -and $_.Enabled -eq $true} | ft Name,Enabled,SipAddress -auto | Tee-Object -FilePath C:\Output\DisabledADaccounts.txt


Any Comments are Welcome :) 

Lync BackUP Powershell Script

This Script is to take the Back up of Lync using Power Shell Script .

$BackupPath = "C:\BackupLync" ( Change the Backup path according to your's)
$FileStore = "\\Lync01.Contoso.com\Lyncshare" ( Change File store according to Your's)
$Pool = "lyncpool01.Contoso.Com"        ( Change the pool name)    
$SQLinstance = "lyncrtc.Contoso.com\rtc" ( Change te Sql instance )
$RemoteLocation = "\\lync02\C$\BackupLync" ( Change the Back Up Location)

md $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"

Export-CsConfiguration -FileName $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\Config.zip

Export-CslisConfiguration -FileName $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\CsLISconfig.zip

CD "C:\Program Files\Common Files\Microsoft Lync Server 2010\Support\"
./DBImpExp.exe /hrxmlfile:"$BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\UserData.xml" /sqlserver:$SQLinstance

CD "C:\Program Files\Microsoft Lync Server 2010\ResKit\"
Import-Module .\RgsImportExport.ps1
Export-CsRgsConfiguration -Source applicationserver:$Pool –FileName $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\RGSconfig.zip

md $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\FileStore
xcopy /E /C /H /K /O $FileStore $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\FileStore > $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\FileStore\FileStoreFileCopyList.txt

Get-CsTopology -AsXML | Out-File $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))"\CSTopology.xml

md \\lync01\C$\BackupLync\"backup_$((get-date).toString('ddMMyyyy'))"
xcopy /E /C /H /K /O $BackupPath\"backup_$((get-date).toString('ddMMyyyy'))" $RemoteLocation\"backup_$((get-date).toString('ddMMyyyy'))"


Any Comments are Welcome :)