Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Multi-Cloud Service Orchestration & Delivery Platform

Remotely Creating Lync Simple URL – Lync Automation Solution

R

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.

<

p style=”text-align: justify;”>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

Multi-Cloud Service Orchestration & Delivery Platform

Connect with MachSol

MachSol is Microsoft Certified Partner and Microsoft Validated Vendor having years of experience in cloud automation industry.

Categories