PS One Liners

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

Export all OCS users to csv
Get-CsUser -onofficecommunicationserver | Format-Table -Property DisplayName, sipaddress | Export-Csv –Path C:\OCSUsers.csv

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 “<pool FQDN>”

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”

Unassigned Numbers routed to IVR (No announcement in this case)
New-CsAnnouncement -Parent service:ApplicationServer:<Lync FE FQDN> -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:<Lync FE FQDN> -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 <Identity of user> -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 -<Identity of user> -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 <no conv history policy name>

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 <server FQDN>
OR
Install-CsDatabase -CentralManagementDatabase -SqlServerFqdn <sqlbe FQDN> -SqlInstanceName rtc -DatabasePaths “D:\CSDB-Logs”,”D:\CSDB-Database”,

Can also be removed with
UnInstall-CsDatabase -CentralManagementDatabase -SqlServerFqdn <sqlbeFQDN>

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 Connectivity (Lync 2010)
Remove-CsPublicProvider -Identity MSN

New-CsPublicProvider -Identity Skype -ProxyFqdn federation.messenger.msn.com -IconUrl “https://images.edge.messenger.live.com/Messenger_16x16.png&#8221; -VerificationLevel 2 -Enabled 1

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:<Lync FE FQDN>

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

Get Current Call Volume (and other activity)
get-cswindowsservice

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 =  <sip uri of the affected user>’

Remove the User form the database (do this on all SQL Databases)
dbo.RtcDeleteResource ‘<sip uri of affected user>’

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

 

Advertisements

One Response to PS One Liners

  1. Pingback: PS One Liners | UC Sorted – UCPro

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