Wery often my customers ask for my little list of usefull powershell commands, and one-liners for basic and common administrative tasks when managing SKYPE for Business.
I always urge the admins to move to powershell, but often hear the argument that commands are forgotten and they get the syntax wrong because they do not use it often enough.
I always urge the admins to move to powershell, but often hear the argument that commands are forgotten and they get the syntax wrong because they do not use it often enough.
So hoping that this could be usefull I decided to put together a (work in progress) article collecting my most often used cmd-lets with examples.
Please comment or ask for addiditons..
And as always happy SKYPE’ing.
For a FULL CMD-LET reference please refer to
I will put the commands in categories – and the basic idea is that you could copy this to a ps1 file and when open in Powershell ISE – use “run selction” all the hash-marked lines are supposed to be explanatory 🙂
## For a section and #for a description of the following command.
##General CMD info
#Get all cmdlets for SFB that contains -CsGet-Command *-Cs* -CommandType cmdlet -Module Lync#Get all cmdlets that contains userGet-Command *user* -CommandType cmdlet -Module Lync#Get specific syntax on how to use CMDGet-Help Get-CsUser -Examples#Use -Online to open the TechNet website for specific CMD-LETGet-Help Get-CsUser -Online
#Get all cmdlets for SFB that contains -CsGet-Command *-Cs* -CommandType cmdlet -Module Lync#Get all cmdlets that contains userGet-Command *user* -CommandType cmdlet -Module Lync#Get specific syntax on how to use CMDGet-Help Get-CsUser -Examples#Use -Online to open the TechNet website for specific CMD-LETGet-Help Get-CsUser -Online
##Manage Users
#Enable New user
enable-csuser -identity domaininit -registrarpool pool@fqdn.com -sipaddresstype emailaddress
#Enable Enterprise voice
set-csuser -identity “username” -enterprisevoiceenabled $TRUE -lineuri “tel:+4529337043“
#Temoporarily disable userSet-CsUser -Identity “Username” -Enabled $False#Re-enable disabled userSet-CsUser -Identity “Username” -Enabled $True#Find all users that are enabled for Lync and have a LineUri, sort them by LineUri, display displayname and LineUri
Get-CsUser -Filter {LineURI -ne $Null} | sort -Property LineURI | ft DisplayName,LineURI
#Find user disabled in AD , but still active on SFB serverGet-CsAdUser -ResultSize Unlimited | Where-Object {$_.UserAccountControl -match “AccountDisabled” -and $_.Enabled -eq $true} | Format-Table Name,Enabled,SipAddress -auto
#Get users from AD in specific OU in order to enable (via pipe)
GET-Aduser –filter * -searchbase ‘OU=Users,OU=Denmark,DC=spinne,DC=local’ | Foreach { ENABLE-CSAduser –identity $_.Name –RegistrarPool ‘poolFQDN’ –sipaddresstype FirstnameLastname –sipdomain sipdomain.com }
#Import Photo to AD$photo = [byte[]](Get-Content C:thomas.jpg -Encoding byte)Set-ADUser domaininit -Replace @{thumbnailPhoto=$photo}#Assign pinSet-CsClientPin “Username” -Pin 12345
#Enable New user
enable-csuser -identity domaininit -registrarpool pool@fqdn.com -sipaddresstype emailaddress
#Enable Enterprise voice
set-csuser -identity “username” -enterprisevoiceenabled $TRUE -lineuri “tel:+4529337043“
#Temoporarily disable userSet-CsUser -Identity “Username” -Enabled $False#Re-enable disabled userSet-CsUser -Identity “Username” -Enabled $True#Find all users that are enabled for Lync and have a LineUri, sort them by LineUri, display displayname and LineUri
Get-CsUser -Filter {LineURI -ne $Null} | sort -Property LineURI | ft DisplayName,LineURI
#Find user disabled in AD , but still active on SFB serverGet-CsAdUser -ResultSize Unlimited | Where-Object {$_.UserAccountControl -match “AccountDisabled” -and $_.Enabled -eq $true} | Format-Table Name,Enabled,SipAddress -auto
#Get users from AD in specific OU in order to enable (via pipe)
GET-Aduser –filter * -searchbase ‘OU=Users,OU=Denmark,DC=spinne,DC=local’ | Foreach { ENABLE-CSAduser –identity $_.Name –RegistrarPool ‘poolFQDN’ –sipaddresstype FirstnameLastname –sipdomain sipdomain.com }
#Import Photo to AD$photo = [byte[]](Get-Content C:thomas.jpg -Encoding byte)Set-ADUser domaininit -Replace @{thumbnailPhoto=$photo}#Assign pinSet-CsClientPin “Username” -Pin 12345
##Policies#View client policyget-csclientpolicy -identity “policyname”#grant policy to all users Get-CsUser | Grant-CsClientPolicy -PolicyName “policy”#grant policy to users of specifik departmentGet-CsUser -LDAPFilter “Department=Eksempel” | Grant-CsClientPolicy -PolicyName “policy”#Create new policy with default settingsnew-csclientpolicy -identity “Newpolicyname”#change policy Boolean valuesset-csclientpolicy -enableeventlogging $true#change other values in policySet-csclientpolicy -tracinglevel Full
##Topology
#List the CMS replication status for each Lync Server
Get-csmanagementstorereplicationsstatus
#Force replication to take place
invoke-csmanagementstorereplication#Get Users Pool infoGet-CsUserPoolInfo sip:username@domain.com
#List the CMS replication status for each Lync Server
Get-csmanagementstorereplicationsstatus
#Force replication to take place
invoke-csmanagementstorereplication#Get Users Pool infoGet-CsUserPoolInfo sip:username@domain.com
##Manage Services#Start any stopped servicesGet-CsWindowsService -ExcludeActivityLevel | where {$_.Status -like “Stopped”} | Start-CsWindowsService#Start all servicesstart-cswindowsservice#Stop all servicesstop-cswindowsservice
##Address Book Sync
#Write changes in backend DB to the address book filesUpdate-CsAddressBook # Synchronize data between AD and Lync backend DB (rtcab)Update-CsUserDatabase
#Write changes in backend DB to the address book filesUpdate-CsAddressBook # Synchronize data between AD and Lync backend DB (rtcab)Update-CsUserDatabase
## Manage Announcement Service
#New Announcement with forward to SIP AddressNew-CsAnnouncement -Parent service:ApplicationServer:pool@fqdn.com -Name “<Name>” -TargetUri sip:<sip address>#New Announcement with forward to PSTN-NumberNew-CsAnnouncement -Parent service:ApplicationServer:pool@fqdn.com -Name “<Name>” -TargetUri “sip:+4529337043@sipdomain.com;user=phone”#New Announcement to Play Audio FileImport-CsAnnouncementFile -Parent “service:ApplicationServer:pool@fqdn.com” -FileName “<AudioFile.wav>” -Content (Get-Content “<path to audio file>” -ReadCount 0 -Encoding Byte) New-CsAnnouncement -Identity “service:ApplicationServer:pool@fqdn.com” -Name “<Name>” -AudioFilePrompt “<AudioFile.wav>”
#New Announcement with forward to SIP AddressNew-CsAnnouncement -Parent service:ApplicationServer:pool@fqdn.com -Name “<Name>” -TargetUri sip:<sip address>#New Announcement with forward to PSTN-NumberNew-CsAnnouncement -Parent service:ApplicationServer:pool@fqdn.com -Name “<Name>” -TargetUri “sip:+4529337043@sipdomain.com;user=phone”#New Announcement to Play Audio FileImport-CsAnnouncementFile -Parent “service:ApplicationServer:pool@fqdn.com” -FileName “<AudioFile.wav>” -Content (Get-Content “<path to audio file>” -ReadCount 0 -Encoding Byte) New-CsAnnouncement -Identity “service:ApplicationServer:pool@fqdn.com” -Name “<Name>” -AudioFilePrompt “<AudioFile.wav>”