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 :) 


Monday, January 5, 2015

Lync 2013 + Exchange Owa 2013 Integration

 

In this Bolg we will see how to integrate Lync 2013 with Exchange OWA 2013.

Before proceeding to the integration first we have to check if auto discover URL and the Service is Published at the Exchange end.

Open Exchange Management shell

And type

Get-ClientAccessServer | Select-Object Name, AutoDiscoverServiceInternalUri | Format-List or with the following command Get-ClientAccessServer | fl fqdn, AutodiscoverServiceInternalURI

Under Auto Discover URL you should see https://autodiscover.contoso.com/autodiscover/autodiscover.xml.

clip_image002

If the URL is Blank you can set the URL by this command

Get-ClientAccessServer | Set-ClientAccessServer -AutoDiscoverServiceInternalUri https://autodiscover.contoso.com/autodiscover/autodiscover.xml

Now we have to set the Autodiscover Service

The Autodiscover service does the following:

Automatically configures user profile settings for clients running Microsoft Office Outlook 2007, Outlook 2010, or Outlook 2013, as well as supported mobile phones. Phones running Windows Mobile 6.1 or a later version are supported. If your phone isn't a Windows Mobile phone, check your mobile phone documentation to see if it's supported.

Provides access to Exchange features for Outlook 2007, Outlook 2010, or Outlook 2013 clients that are connected to your Exchange messaging environment.

Uses a user's email address and password to provide profile settings to Outlook 2007, Outlook 2010, or Outlook 2013 clients and supported mobile phones. If the Outlook client is joined to a domain, the user's domain account is used.

Set-CsOAuthConfiguration -Identity global -ExchangeAutodiscoverUrl https://autodiscover.contoso.com/autodiscover/autodiscover.svc

Now we have to identify the certificate that has been assigned in IIS

Here is the command to get the certificate Thumprint Information

Get-ExchangeCertificate|fl Services,Thumbprint

clip_image004

Copy the certificate Thumbprint in the later stage we will be using this certificate Thumprint. 5EA8831E757FBB86808B95B69F81D01A2FC2F55A

To get the owa virtual directory . to make sure you have only single owa virtual directory configured in your environment

Get-OWAVirtualDirectory

clip_image006

Use the below command to assign the pool name of lync server and the certificate thumbprint to OWA virtual directory. Now this enables IM capabilities for you exchange environment.

Get-OwaVirtualDirectory | Set-OwaVirtualDirectory -InstantMessagingType OCS -InstantMessagingEnabled:$true –InstantMessagingCertificateThumbprint 5EA8831E757FBB86808B95B69F81D01A2FC2F55A -InstantMessagingServerName pool.contoso.com

Next we must add the following two lines to Outlook Web App Web.config which will be available in this path C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess\Owa

In this path you see an file web.config file open the file in notepad. under <AppSettings> add the below two lines

<add key="IMCertificateThumbprint" value="5EA8831E757FBB86808B95B69F81D01A2FC2F55A "/>

<add key="IMServerName" value="pool.contoso.com"/>

clip_image008

Now try to perform IIS reset in the Command prompt

Iisreset

clip_image010

At the Lync server End Configuration

Now login to your lync front end and open the Lync Management shell

To get he SITE ID of lync enter the Below Command we will be using Lync Site id while configuring the Exchange trusted Application.

Get-CsSite

We have to create the Trusted Application pool for Excahnge OWA to create the one use the following command

New-CsTrustedApplicationPool -Identity <Certificate Subject name of client access server> -Registrar <Pool FQDN of Lync server> -Site <Lync Site Name> -RequiresReplication $False

After creating the trusted application pool, use the following command to configure an application Identity and a port for Outlook Web App

Before executing the below command check if the port is not using any other application. You can use any port but make sure to check the port is available

netstat -a | findstr 5199

New-CsTrustedApplication -ApplicationId OutlookWebAccess -TrustedApplicationPoolFqdn < Certificate Subject name of client access server> -Port 5199

Now use this command to apply the configuration changes Enable-CsTopology. This command but publishing the Lync Topology.

Enable-CsTopology.

Now it’s testing time. Try logging to OWA and click on sing to IM in OWA web page

clip_image012

Successfully logged in to IM using OWA

clip_image014

Now we will be able to IM with Lync users form OWA itself.

Trouble shooting Lync OWA Integration.

1) Make sure that our OWA Virtual Directory enabled for Instant Messaging

Get-OwaVirtualDirectory -Server <Excahnge server> | Set-OwaVirtualDirectory -InstantMessagingEnable $True -InstantMessagingType OCS

2) Make sure that in the OWA Web config file you have added these lines

<add key="IMCertificateThumbprint" value="5EA8831E757FBB86808B95B69F81D01A2FC2F55A <Your Certificate Thumbprint> "/>

<add key="IMServerName" value="pool.contosot.com"/>

3) To start the trace and to get the Log file

On the exchange server you can use OcsTracer.exe in the following path C:\Program Files\Microsoft UCMA 4.0\Runtime\Tracing

To start the trace use the command prompt and go the path enter below command

OCSTracer.exe Start /Component:Collaboration,TL_noise,tf_component,tf_diag,tf_protocol,tf_connection /Component:S4,TL_VERBOSE,tf_component,tf_protocol /LogFileMode:NewFile,20

To Stop Logging

OCSTracer Stop /Component:Collaboration /component:s4 /OutputFile:traces.txt /View

It will open the Notepad file so that you check the logs.

Monday, December 29, 2014

Lync 2013 + Asterisk PBX integration

Lync 2013 + Asterisk Integration


Integrating Lync 2013 with Asterisk.

In this Blog I am going to explain how to integrate Lync 2013 with Asterisk PBX ( Elastix)
Assuming already lync 2013 in place and Asterisk pbx installed. I have the following setup.
1)      Lync 2013 Standard Edition Server Installed in Hyper-v
2)      Asterisk PBX ( Elastix) has been installed in  in Hyper-v
If Lync 2013 is not installed in you environment please try to Download the one and follow this step by step guide to install the Lync 2013
In my Environment I am using Elastix as my PBX you can download elastix for free check it out
Guide to install Elastix PBX
Asterisk PBX Side Configuration
if you want to integrate any PBX with Lync we have to create an SIP Trunk for the Integration. Now we will create an SIP trunk in the PBX.
Before proceeding further we have to make few changes in the PBX Configuration. As you know the lync will be working on TCP we have to Bing our PBX to TCP to do this we have to edit the file under etc/asterisk/sip_custom.conf file we have to add this two. After adding this restart the asterisk service to restart asterisk /etc/init.d/asterisk restart
tcpenable=yes
transport=tcp

Once you success fully installed the Elastix pbx if you type your PBX Ip address you will see this page enter the credentials  to login.

Then click on the PBX to configure the SIP trunk
Now click on the trunks
 Then  click on the Add SIP trunk
On the Outgoing setting, type trunk name, on the peers detail,
And no need to enter any Incoming settings just Leave it Blank.
host=IP Address of Lync/mediation server IP Address.
transport=tcp,udp
port=5060 Lync Mediation server Listening Port.
insecure=very
type=peer
canreinvite=yes
qualify=no
context=from-internal
Once you added the Sip Trunk in PBX if you want to check enter this command asterisk –r
The type this command sip show peers here it is I can see my sip trunk.
We have created the SIP trunk in the PBX end now we will be creating PBX extensions
Click on  Extension  and create the PBX Extension
Enter the Extension Number ex: 1000 and the Display name.

Change the Transport to TCP Only because the Lync will work on TCP
Now we will be configuring the outbound rules for calling to Lync enter the name
 Create the Route Pattern in my case I have created the 10 digit extension in Lync  

At Lync End Configuration 

Open the Topology Builder. And change the TCP port to 5060 if it is listening on different port

Adding the SIP Trunk to the Lync Topology

To add the SIP Trunk to the Topology as a new PSTN Gateway, add a new PSTN Gateway as follows in Topology Builder:
Define the PSTN Gateway FQDN = IP Address of the external SIP Trunk
Define the Root Trunk (the associated trunk can be defined at the same time you create the PSTN gateway)
Trunk Name: <IP address of the SIP trunk>
Listening port for IP/PSTN Gateway: 5060   (in this case unencrypted TCP is being used; use 5061 for TLS encrypted)
Transport: TCP
Associated Mediation Server:  <Lync Front End Pool + Lync Site>
Associated Mediation Server port:  5060
Once the sip trunk added don’t forget to Publish the Topology.
Now open the Control Panel to create the dial plans.
Under control panel select the Voice Routing to create the Dial plan. Under Dial plan create an new site/pool plan.

Select the Register server

Enter the details
Under Associated Normalization Rules Select New. Here I have created two new Normalization rules one for my PBX Extensions (Ex: 1000) and one for Lync Extensions (ex: 1234567890).
As my extension length is 4 I have selected exactly 4 and we have to add + here because lync will know only E.164 (ex:+1000) as my pbx will not accept the + when the incoming call is coming I will delete this + in the later stage.
The second normalization rule is for my Lync extensions. Now it’s time to add the routes in the routes we will associate the SIP trunk which we have created. Select the route. Under the associated PSTN Usages select the SIP which we have created earlier.
Now it’s time to configure Trunk  Configuration as I said earlier PBX will not understand +1000 it doesn’t know this format in the Trunk configuration we will remove the + when sending the calls to PBX.
Check this if you are not removing the + sing this is what the out put
chan_sip.c:25627 handle_request_invite: Call from 'Lync1' (64.65.67.68:62146) to extension '+1000' rejected because extension not found in context 'from-internal'.
Under Called number Translation rules
 Select New
Now It’s time to Test the call in between Lync and Asterisk PBX.
Call between Pbx and Lync.


 between Lync and PBX
I thought to share Integration between Lync and Asterisk. Hope this help who are looking for Lync asterisk Integration. Any Comments are Welcome :)  

Saturday, July 19, 2014

Microsoft Lync Phone Edition HotFix

Microsoft Lync Phone Edition ( Polycom , Astra , HP) July 2014 HotFix are available for Download

Microsoft Lync Phone Edition for Aastra 6721ip and Aastra 6725ip  Click Here to Download


Microsoft Lync Phone Edition for HP 4110 and HP 4120 Click Here to Download


Microsoft Lync Phone Edition for Polycom CX500, Polycom CX600 and Polycom CX3000 Click Here to Download  



Wednesday, May 8, 2013

Step by Step Configuring Data Base Mirroring for Lync 2013

Configure Data Base Mirroring Lync for 2013

As we know SQL Clustering is not Supported. But you can still use it but Microsoft will not support it.

In this Blog we will see how to create SQL Mirroring 

In this i will be using as i did in my Lab I have Configured two sql server in my Enterprise pool Sql01 and Sql02.

And I will be using Witness server has my Domain controller For just the Lab purpose. In my DC Sql server 

First we will be creating SQL Mirror File Share in my Domain Controller 

Create a Folder SQLMirrorShare under C drive 
1) Right Click the newly created Folder SQLMirrorShare and select Properties
2) Click the Sharing tab. Then Click Advanced Sharing Button.
3) Check the "Share this folder" Checkbox
4) Click the Permissions button.
5) In the permissions for SQLMirrorShare dialog box, Click Everyone group and the Remove it.
6)Click the Add button.click the object types button. In the object types dialog box select service accounts checkbox. Leave the other checkboxes checked and clieck ok
7).  In the Enter the object names to select textbox, type in Administrators;SQLSvc and click Check
Names. Ensure that both entries are underlined, and click Ok
8).   In the Permissions for SQLMirrorShare dialog, click the Administrators group, and check the Full
Control checkbox in the Allow column
9)Still in the Permissions for SQLMirrorShare dialog, click the SQLSvc user account, and check the
Full Control checkbox in the Allow column
10)Click Ok to return to the Advanced Sharing Dialog box. Click OK, then click Close


Now go to Front End server 

Start and then click Lync Server Topology Builder

1) In the Topology Builder, expand Lync Server, expand Lync Server 2013, and then expand Enterprise Edition Front End pools
2) Right-click pool.contoso.com and then click Edit Properties
3)On the Edit Properties page, under Associations, select the Enable SQL store mirroring check box
and then click New
4)In the Define New SQL Server Store window, in the SQL Server FQDN box, type sql02.contoso.com
5)Select Named Instance, and then in the box, type Lync2013 (Note: It is instance name which we will be giving while installing SQL)
6)Take note of the default mirror port number given and then click OK
7)In the Edit Properties dialog box, under Associations, select the Use SQL Server mirroring witness to enable automatic failover checkbox and then click Ne
8    8) In the Define New SQL Server Store window, in the SQL Server FQDN box, type dc1.contoso.com (Note: This is nothing but the Witness server at the beginning  which we have created the sql mirror share in my case i have used DC because of Lab purpose)
      9)Select Named Instance, and then in the box, type Lync2013
     10)Take note of the default mirror port number given and then click OK
     11 On FE01, in the Topology Builder, expand Shared Components and then expand SQL Server stores
     12) Right-click test-sql01.contoso.com\Lync2013 and then click Edit Properties
     13).    In the Edit Properties window, in the Mirror port number box, type 5022 and then click OK
    
     Now Go to FE server In the Topology Builder select Lync server 2013 right click and then Publish 
      1) On the Publish the topology page, review the actions that should be completed and then click Next
      2)On the Create mirror databases page, verify that test-sql02.contoso.com has a check in the checkbox.
      3)Click test-sql02.contoso.com and then click Settings
      3)In the Mirror Database Settings window, in the Path to file share box, type \\dc- dc1.contoso.com\SQLMirrorShare and then click OK ( Note: The Sqlmirror share FQDN)
      4)Back on the Create mirror databases page, click Next
      5)Wait as the topology is published
      6)On the Publishing wizard complete page, click Finish


      Now we will verify the Configuration in SQL using Sql Management studio

     1) Log in to test-SQL01, click Start, and then click SQL Management Studio and connect to the server.
     2) In the Object Explorer Expand Databases it will show as Principal, Synchronized

     


      





3) Right click cpsdyn (Principal, Synchronized), select Tasks, Mirror. you will Notice under Operating mode, that High safety mode with automatic failover (synchronous) is selected








Now Log in to Second Sql server test-SQL02 then click SQL Management Studio

1) Connect to the server In the Object Explorer Expand Database 
2) You will notice Notice the databases listed show as (Mirror, Synchronized / Restoring) as Below Screen shot 





To check the replication status Get-CsDatabaseMirrorState –PoolFqdn pool.contoso.com –DatabaseType User



Fail over the databases to the mirrored instance go to FE in the Lync Management Shell Type this command

Invoke-CsDatabaseFailover –PoolFqdn lon-pool.adatum.com –DatabaseType User –NewPrincipal mirror  



Once your Sql primary is back online and you want to fallback to Primary

 Fail the database instances back to the original primary SQL instance go to FE in Lync Management Shell Type this command 

Invoke-CsDatabaseFailover –PoolFqdn lon-pool.adatum.com –DatabaseType User –NewPrincipal
Primary

once you execute this command it will prompt to perform then Type A then hit Enter 

Once you have executed to check if it is fall back to Primary 

Get-CsDatabaseMirrorState –PoolFqdn pool.contoso.com –DatabaseType User 

You see this results


DatabaseName            : rtcab
StateOnPrimary          : Principal
StateOnMirror           : Mirror 
MirroringStatusOnPrimary : synchronized 
MirroringStatusOnMirror : synchronized





As This is my First Blog you might see the mistakes. It would be helpful to me if you can comment any updates are issues so that i can correct it.