Click here to Skip to main content
15,749,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Updated 15-Feb-17 22: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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900