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
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
In case you wondered the file looks like this:
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.