A collection of useful Scripts and commands
Get Server Version and CU Update level
Get-WmiObject –query ‘select * from win32_product’ | where {$_.name –like “Microsoft Lync Server*”} | ft Name, Version –AutoSize
Get Last Logon Time for all Skype for Business Users
$SFBUsers = get-csuser
foreach ($user in $SFBUsers){
get-aduser $user.SamAccountName -properties * | Select-Object Name, @{ Name = “Stamp”; Expression = { [DateTime]::FromFileTime($_.lastLogon).ToString(‘yyyy-MM-dd’) } }
}
Export all Lync users to csv (examples)
Get-CsUser | select-object DisplayName,LineUri,EnterpriseVoiceEnabled | export-csv c:\users.csv
Get-CsUser | Format-Table DisplayName, Enabled, SipAddress | Export-Csv –Path C:\Users.csv
NOTE
The above command excludes Common Area Phones and Meeting Rooms
Enable all users in an OU for Lync
get-csADuser -OU “OU=Users,OU=Auckland,dc=ucsorted,dc=com” | Enable-CsUser -RegistrarPool pool01.ucsorted.com -SipAddressType emailaddress
Enable all users in an OU for Lync (exporting these to csv)
Get-CsADuser | Format-Table DisplayName | Export-Csv –Path C:\ADUsers.csv
get-csADuser -OU “OU=Users,OU=Auckland,dc=ucsorted,dc=com” | Enable-CsUser -RegistrarPool pool01.ucsorted.com -SipAddressType emailaddress
Take all the users still homed on OCS and migrates all to Lync Server:
Get-CsUser –OnOfficeCommunicationServer | Move-CsLegacyUser –Target “”
Normalization to ITSP – Removing Extension numbers
New-CsOutBoundCallingNumberTranslationRule -Parent Global -Pattern “^(\+\d+)(\s*\S)*$” -Translation ‘$1’ -Name “Remove Extensions”
Edge
Creating a config file to feed Edge server (not on the Domain)
Export-CsConfiguration -FileName “C:\Config.zip”
Who is federating with me?
Get-EventLog “lync server” | ? {$_.eventid -eq 14601} | Select eventid,message -First 1 | fl *
Unassigned Numbers routed to IVR (No announcement in this case)
New-CsAnnouncement -Parent service:ApplicationServer: -Name “Unassigned numbers to IVR” -TargetUri “sip:+649377xxx@ucsorted.com;user=phone”
Added the range in Lync Manager – Voice Features – Unassigned Numbers – Range +6499502500 – +64999502599 (covers all unassigned numbers from 500 – 599)
Unassigned Numbers (Text Announcement)
New-CsAnnouncement -Parent service:ApplicationServer: -Name “Unassigned Numbers” -TextToSpeechPrompt “The Number you have dialed is not currently in use, please hold to be transferred to an operator.” -Language “en-US” -TargetUri sip:reception@ucsorted.com
Assigning a Private Telephone Line Number
Set-CsUser -Identity “sip:paulb@lynclab.co.nz” -PrivateLine “Tel:+6499502534”.
Removing Private Lines
Set-CsUser -PrivateLine $NULL
Show All Users that have Private Lines
Get-CsUser | Where {$_.privateline -ne “”} | FL Identity, PrivateLine
Move All users in an OU to a common Voice Policy
Get-CsUser -OU “ou=users,dc=ucsorted,dc=com” | Grant-CsVoicePolicy -PolicyName “SIP Voice Policy”
Get numbers stored in AD
get-aduser – -properties *|Format-List name, mobile,telephoneNumber,msRTCSIP-Line
Enabling MoH Globally
Set-CSClientPolicy Global -EnableClientMusicOnHold:$TRUE
MoH Policy to force company wide MoH
Set-CSClientPolicy -EnableClientMusicOnHold:$TRUE -MusicOnHoldAudioFile pathtoaudiofile.wma
(keep in mind that this needs to be a path the clients can access to collect the music file)
Stop notification of being added as a contact
set-CSClientPolicy – EnableNotificationForNewSubscribers $False
Changing the DG refresh interval from 8 days (default) to 5 minutes
set-CSClientPolicy global -DGrefreshinterval:00:05:00
Make Lync Call Default
Set-CsClientPolicy -EnableVOIPCallDefault $True
Disable Save activity in Outlook Conversation History
Set-CsClientPolicy –EnableIMAutoArchiving $false –EnableCallLogAutoArchiving $false
(Can always create a seperate policy using the – Identity
Extending the Distribution Group Expansion size limit
Set-CsWebServiceConfiguration – Shows current limit (default 100)
Set-CsWebServiceConfiguration -maxgroupsizetoexpand 200
GAL Download or Web Query
Set-CsClientPolicy -AddressBookAvailability websearchonly
Prevent Lync from synchronizing with Outlook contact
set-csclientPolicy -identity:global -ExcludedContactFolders “Contacts;Suggested Contacts”
Replication
Get-CsManagementStoreReplicationStatus
Invoke-CsManagementStoreReplication
Forcing an Update from the Server
Update-CsAddressBook -verbose (ABServer -SyncNow) wait 5 minutes
Finding Contact Merge issues
Debug-CsAddressBookReplication
Export AddressBook
.\abserver.exe -dumpfile “C:\LyncShare\1-WebServices-1\ABFiles0000000-0000-0000-0000-0000000000000000000-0000-0000-0000-000000000000\F-13cc.lsabs” c:\temp\Export-ABS.txt
Graceful Shut Down
Stop-CsWindowsService -Graceful
Installation of Windows Identity Foundation
Add-WindowsFeature Windows-Identity-Foundation
CMS Database
Lync SE – dont need to define server FQDN (generally this is done by prep first SE)
Lync EE
Install-CsDatabase -CentralManagementDatabase -SqlServerFqdn
OR
Install-CsDatabase -CentralManagementDatabase -SqlServerFqdn -SqlInstanceName rtc -DatabasePaths “D:\CSDB-Logs”,”D:\CSDB-Database”,
Can also be removed with
UnInstall-CsDatabase -CentralManagementDatabase -SqlServerFqdn
Testing CsDatabase
Test-CsDatabase -ConfiguredDatabases | ft databasen*,Expe*,Inst*,Suc* -AutoSize
Enable UM
enable-ummailbox -identity paul@lynconline.co.nz –extensions 1234 -ummailboxpolicy DefaultUMPolicy –SIPResourceIdentifier paul@lynconline.co.nz
Test DHCP (using DHCPUtil.exe from the RESKit)
From directory where DHCPUtil.exe lives (could be copied to anywhere for convenience)
run
DHCPUtil.exe -emulateclient
Phone Lock
set-CsUcPhoneConfiguration EnforcePhoneLock $false
Test Phone Number and PIN Login
Test-CsPhoneBootstrap -PhoneOrExt 1234 -PIN 10101 -verbose
Clear User Caching
set-csuser -identity paul@lynconline.co.nz -clearCacheOnNextSignIn:$true”
Skype Consumer Connectivity (Lync 2010\2013 &SFB)
Remove-CsPublicProvider -Identity MSN
New-CsPublicProvider -Identity Skype -ProxyFqdn federation.messenger.msn.com -IconUrl “https://images.edge.messenger.live.com/Messenger_16x16.png” -VerificationLevel 2 -Enabled 1
NOTE The Edge Server for Federation needs to have access to skypegraph.skype.com on Port 443
Lync 2013 New
Show-Command
Trusted applications and policy settings
Get-CsTrustedApplicationEndpoint -Identity “sip:ZCCCallCenter@lynclab.co.nz” | Select-Object *
Response Group Failover
Export-CsRgsConfiguration -FileName “c:\RGSBackup.zip” -Source service:applicationserver:
Hide Response Group from AddressBook
Get-ADObject -SearchBase “CN=Application Contacts,CN=RTC Service,CN=Services,CN=Configuration,DC=ucsorted,DC=com” -Filter {msRTCSIP-PrimaryUserAddress -eq “sip:nightshiftRGS@ucsorted.com”} | Set-AdObject -replace @{msExchHideFromAddressLists=$true}
OR Hide a selection based on a filter
Get-ADObject -SearchBase “CN=Application Contacts,CN=RTC
Service,CN=Services,CN=Configuration,DC=ucsorted,DC=com” -Filter {msRTCSIP-Prim
aryUserAddress -like “*failover@ucsorted.com”} | Set-AdObject -replace @{msExchHide
FromAddressLists=$true}
Get all configuration overview
Get-CsService | out-file C:\MyLyncConfiguration.txt
User Pool Assignment
get-csuserpoolinfo -identity paulb@lynconline.co.nz
Finding orphaned users in SQL Database
Find the user in the database
SELECT [ResourceId],[UserAtHost] FROM [rtc].[dbo].[Resource]Where UserAtHost = ‘
Remove the User form the database (do this on all SQL Databases)
dbo.RtcDeleteResource ”
Mobility – Enabling Push Notification
Set-CsPushNotificationConfiguration -EnableApple
PushNotificationService $true -EnableMicrosoftPushNotificationService $true
Skype Directory Button Mission
Remove-CsPublicProvider -Identity Skype
New-CsPublicProvider -Identity Skype -ProxyFqdn federation.messenger.msn.com -IconUrl https://images.edge.messenger.live.com/Messenger_16x16.png -NameDecorationRoutingDomain msn.com -NameDecorationExcludedDomainList “msn.com,outlook.com,live.com,hotmail.com” -VerificationLevel UseSourceVerification -Enabled $True -EnableSkypeDirectorySearch $True -EnableSkypeIdRouting $True
Testing Databases
Test-CsDatabase -ConfiguredDatabases | ft databasen*,Expe*,Inst*,Suc* -AutoSize
Setting Windows Fabric log files to circular to avoid disk bloat. Run from elevated CMD
Logman update trace FabricLeaseLayerTraces -f bincirc –cnf
Pingback: PS One Liners | UC Sorted – UCPro