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.

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.

  • 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 '16 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.