Click here to Skip to main content
13,794,579 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hey there,

I am trying to execute exe file through a powershell remove session, but got stuck with some oddness...
The exe that I am executing is connecting to a database using local connected used credentials and gets the stuff from DB (IntegratedSecurity = true)
Now - when I connect to the remote machine with user "Manager" through remote desktop and run the exe - it's fine.
But - when I run this through powershell:

$results = Invoke-Command -ComputerName Dust_1 -Credential $credentials -ScriptBlock {
	$ArgList = 'scope_Items_1', '--saveReport';
	$ps = Start-Process 'C:\DataComparer\Comparer.exe' -ArgumentList $ArgList -NoNewWindow -Wait
	return $ps;

I am getting an error: "
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

Any ideas what is happening here?
I even tried executing this inside the script block:
Write-Host $env:UserName;

And it printed out "Manager" and that is correct and now it looks like I am connected with the right user "manager", but when I try to run something remotely - it executes as some NT AUTHORITY\ANONYMOUS LOGON....
So - I'm kind of lost here....

Any thoughts?

Thanks in advance!

What I have tried:

tried various ways of executing the exe but it always executes it with some anonymous logon user...
I've also set the WSManCredSSP to allow to pass and receive credentials - still no joy.
Posted 15-Feb-17 21:51pm
Updated 15-Feb-17 23:36pm
Michael_Davies 16-Feb-17 4:03am
When you say "But - when I run this through powershell:" in what way, if you are running it in Powershell as a logged on user your credentials are that of the logged on user and so long as that user has the right privileges it will run.

What context are you running it under Powershell when it fails.
MK-Gii 16-Feb-17 4:11am
here is the full script:
$credentials = Get-Credential 'accounting\Manager';

$results = Invoke-Command -ComputerName Dust_1 -Credential $credentials -ScriptBlock {
$ArgList = 'scope_Items_1', '--saveReport';
$ps = Start-Process 'C:\DataComparer\Comparer.exe' -ArgumentList $ArgList -NoNewWindow -Wait
return $ps;
basically - I am working on PC_1 and starting new process on PC_2. The PC_2 tries to connect to database using connected user credentials. And it fails because of this wrong user being used for authentication (anonymous)
Michael_Davies 16-Feb-17 6:03am
Do you get asked for the password when you invoke the script on PC_2
MK-Gii 16-Feb-17 7:29am
Nope - I get asked only first time. then I use the same credentials everywhere.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.181207.3 | Last Updated 16 Feb 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100