Archive for March, 2012

Remotely Creating Lync Simple URL – Lync Automation Solution

Thursday, March 22nd, 2012

Lync Management Shell provides an interface for administrators to easily manage Lync server. In different circumstances, even simplest job becomes an unavoidable hurdle. For example, creating Lync simple URL (e.g. https://lync.mydomain/SipDomain/Meet ) using management shell is quite simple by executing the following commands:

$urlEntry = New-CsSimpleUrlEntry -Url "https://lync.MyDomain/SipDomain/Meet"
$simpleUrl = New-CsSimpleUrl -Component "Meet" -Domain "SIPDomain" -SimpleUrl $urlEntry -ActiveUrl "https://lync.MyDomain/SipDomain/Meet"
Set-CsSimpleUrlConfiguration -Identity Global -SimpleUrl @{Add=$simpleUrl}
Enable-CSComputer

Above commands once executed will create simple URL but this easy task becomes quite difficult if you had to do it remotely (for any purpose like an automation solution for Lync management). Inside a vb.net code above shell cmdlets were called. But upon execution below error came: Assignment statements are not allowed in restricted language mode or a Data section.

Few solutions to bypass above error were tried like setting execution policy to unrestricted , using admin credentials for remote session etc. , but all in vain.

However, another approach was used to get this task done by saving these cmdlets in a ps1 file and executing the file. Following is the code snippet that does this:

Try
Proc.StartInfo.FileName = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
Dim ScriptFile As String = “C:\Script.ps1”
Dim PSCommand As String = "Import-Module Lync" & vbCrLf
PSCommand &= Command
File.AppendAllText(ScriptFile, PSCommand)
Proc.StartInfo.Domain = DomainNETBIOS
Proc.StartInfo.UserName = ADUserName
Proc.StartInfo.LoadUserProfile = True
Dim Pass As New System.Security.SecureString
For Each character As Char In ADPassword
Pass.AppendChar(character)
Next
Proc.StartInfo.Password = Pass
Proc.StartInfo.UseShellExecute = False
Proc.StartInfo.RedirectStandardError = True
Proc.StartInfo.RedirectStandardOutput = True
Proc.StartInfo.Arguments = " -ExecutionPolicy Unrestricted -Command &'" & ScriptFile & "'"
Proc.Start()
Proc.WaitForExit()
If Not Proc.StandardError Is Nothing Then
Dim ErrorMsg As String = Proc.StandardError.ReadToEnd
If ErrorMsg <> "" Then
Throw New Exception(ErrorMsg)
End If
End If
Proc = Nothing
File.Delete(ScriptFile)
Catch ex As Exception
Throw New Exception("Error processing PS command: " & ex.Message)
End Try

 

Often you will find that new approach to a problem is better than focusing all efforts in one direction

Related Posts:

SharePoint 2010 – Ensure High Availability with SQL Mirroring

Monday, March 19th, 2012

High Availability – Data Tier

SharePoint 2010 provides rich integration with SQL Server enabling SharePoint administrators to leverage the high availability solutions provided by Microsoft SQL Server. Changes include support for the Fail-over_Partner keyword, which enables SharePoint 2010 to natively interpret/translate and respond to state changes in a database mirroring topology. Following is brief of how to accomplish SQL Mirroring.

SQL Mirroring – The Native Way

Since SharePoint 2010 has built-in support for SQL mirroring so farm administrator can configure the SQL environment to mirror a SharePoint content database. When a new database is created, the SharePoint administrator will be prompted to enter the fail-over server. SharePoint then communicates with the witness server, and if issues are discovered, SharePoint will fail-over to the hot backup of the environment. Following image shows the configuration:

Related Posts: