6

Using my favourite PowerShell module I was wondering how to access the Core Service using username and password instead of using the current user's Windows credentials.

The commands in the PowerShell module use the Get-TridionCoreServiceClient commandlet. This uses the current logged on user's credentials to connect to the Core Service. Optionally you can impersonate another user.

Now I am connecting from my local machine to the CMS server, using different credentials so I would like to pass or set my username and password to Get-TridionCoreServiceClient and other commands.

2
  • This is one of the open issues for the PowerShell modules (github.com/pkjaer/tridion-powershell-modules/issues/4). I'll get around to it eventually! If you get something working, please do share or make a pull request :) Oct 10, 2016 at 9:12
  • I will definately do a PR when I get something working.
    – Jan H
    Oct 10, 2016 at 9:20

1 Answer 1

4

I have found a solution to get a CoreServiceClient using a plain username and password.

$client = Get-TridionCoreServiceClient
$credentials = New-Object System.Net.NetworkCredential("username", "password")
$client.ChannelFactory.Credentials.Windows.ClientCredential = $credentials
$client.GetCurrentUser()

This will get a Core Service client object, using the settings set by Set-CoreServiceSettings. Then actually before using the client to call the server the credentials are added.

This however does not work for the other PowerShell module commands. If you would try to use Get-TridionUser instead of $client.GetCurrentUser() it will fail. The Get-TridionUser command will construct a new client without your credentials.

1
  • hmm, Set-CoreServiceSettings has a -Username parameter. I think this username is not used in any of the Tridion-CoreService commandlets.
    – Jan H
    Oct 6, 2016 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.