Share via


Creating a OcsPowerShell PSSession under a different set of credential

I have recently been asked multiple times how to create a PowerShell session to OcsPowerShell.

This is quite easy to do, just remember:

  • Use a secure string for the password: $secure_string_pwd = convertto-securestring "password" -asplaintext -force
  • Create and import the session: $session = New-PSSession -ConnectionUri "https://domain/OcsPowerShell" -Credential $cred

 A complete sample code can be found on this post: Creating a Powershell session under a different set of credentials.

This will allow you to run the OcsPowershell cmdlets under different credentials and be correctly identified by the Role Based Access Control.