#Lync Question 39: Creating a Remote PowerShell session to Lync On-Premise

This is a something that comes from customer on most deployments now as the helpdesk, ,voice and network engineers cannot sadly do everything from the control panel. It is usually due to the need to create Common Area Phones or add Location Information Services Subnets or more increasingly the need to enable users for Hosted Voicemail due to using Exchange Online Unified Messaging.

There are two ways I usually recommended to create a remote PowerShell session to Lync Server On-Premise

1. Manually (via specifying the credential manually)
2. Automatically (via reading the secure password from a file)

Manual

Below is the PowerShell to create a Remote PowerShell against a production Lync environment which can be done from any workstation

$credential = Get-Credential "DomainID\AdminID"
$session = New-PSSession -ConnectionUri "https://admin.uctestlab.com/OcsPowershell" -Credential $credential
Import-PSSession $session

When manually create a Remote PowerShell session Lync, the credentials are required to be enter via the following dialogue box. This is following line #1

PSLogon

This might not be ideal in term of automation.

Automatic

If you need automatically create a Remote PowerShell session within a script then first you need to store the password in a secure string in a file via the following:

Read-host -AsSecureString | ConvertFrom-SecureString | Out-File C:\cred.txt

This is entered straight into the PowerShell window as shown below

PSSecurePassword

In case you wondered the file looks like this:

SecurePassword

Now we have this we can create the Remote Powershell session to Lync using the password in the file via the following:

$password = Get-Content C:\cred.txt | ConvertTo-SecureString
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "DomainID\AdminID",$password
$session = New-PSSession -ConnectionUri "https://admin.uctestlab.com/OcsPowershell" -Credential $credential
Import-PSSession $session

I’m sure there are other ways too, but these two methods meet the majority of requirements with customers.

Advertisements

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