Run exe on remote server under different account - powershell

I need to run an exe on a remote server. I'm using Invoke-Command -UseSSL to initiate the exe on the remote server. The exe does some work but when it needs to connect to the SQL Server, it fails to authenticate. Looking in the server log, it looks like exe are connecting to SQL Server using NT/AUTHORITY account. The security team are not allowing CredssP on the network. Is there any means I can run the exe with an explicitly defined account. An account other than the account that is used to created the remote session with.
Invoke-Command -UseSSL -ComputerName $AppServer -ScriptBlock {&"C:\Program Files\my.exe" "Params"}

Related

remote connection using powershell from linux to windows

I am able to connect to a remote windows machine from my windows local machine using Powershell session created by New-PSSession command.
New-PSSession -ComputerName $computerName -Credential $cred
Now, I need to create similar remote session to a remote windows machine from my local LINUX machine. So, I installed powershell 6.0.2 on my red hat 7 linux box. When trying to create a remote session using New-PSSession command, I am getting following error:
New-PSSession : MI_Result_Access_Denied
I need to use only WinRM based approach and not SSH based as I cannot install any extra utility on remote windows machines.
kerberos auth is not supported in cross domain in its vanilla flavour. and Basic auth over HTTP is not supported from Linux. Installing OpenSSH on windows looks to be only way.

PSS-Remoting problem while connecting to a connection broker to retrieve sessions

Tryin to be synthetic, I'm trying to connecting from a W7 operating system to a connection broker in order to retrieve all of the user's sessions with this simple function:
Get-RDUsersession -connectionbroker 'xx' -collectionname 'xx'
Since I discovered that it can't be done from W7 because the remotedesktop module can't be downloaded even after installed RSAT, some users advise me to use PSSRemoting commands in order to send command on a remote computer where surely the function works and thanks to this way run the entire script i've made on the local computer.
The problem, as you can see in the image attacched, is that it keeps me prompt out this error:
A remote desktop services deployment does not exist on server.se
The same command works on W10 and i'm sure the RDS Deployment exist on that server. I've tried a lot of ways but i can't figure out why it doesn't works.
Someone can help me out ?
You're not really running your command using PowerShell Remoting (H: is not on the remote system as you can see in your screenshot).
Connect to the remote system using:
Enter-PSSession -ComputerName "yourRemoteMachine"
and the run your Get-RDUsersession -connectionbroker "xx" command.

Get host machine name when a script/command is executed powershell Invoke-Command

I have some Powershell scripts for deploying our applications to test machine. These have to be executed using Invoke-Command from the developer machine. Is there anyway to log host machine name/IP from which these scripts are called.
For example:
If developer foo deployed an application using the script from devmachine1 i want to get the name/IP of the devmachine1 and log it in our test machine.
We are using Powershell V4.0. Can upgrade to 5.0 if required.
answering this to mark the question as solved. just incase if some one is looking for an answer.
I am passing computer name $env:COMPUTERNAME as a parameter to the remote script.
Getting the remote username using $PSSenderInfo.ConnectedUser in the remote script.

Working with PowerShell v2 : Remote info from server

I have a question i'm trying to basically write a script to gather server roles information remotely from my pc. i have administrative rights not the server since its just a dummy test server.
What i currently have is the initial cmd :
servermanagercmd.exe -query roles.xml
What i need help understanding is :
How to initialize a connection to the server (My server is a MS 08 R2 64-bit) with remoting enabled.
via Enable -PSRemoting -Force. "As i'm sure i need to pass my login info in the cmd some how to be allowed to run the cmd im passing.
Sending the cmd to the server servermanagercmd.exe -query roles.xml

Why would a get-process -computername return a couldn't connect to remote machine error?

I can execute the following command on a specific machine and it can return a list of processes on several target computers but returns a "Couldn't connect to remote machine" error on one machine.
get-process -ComputerName 192.168.1.101
None of the target machines have powershell installed.
The machine I am executing the powershell script on has 2.0 installed.
I have admin privileges on all machines.
The target machines that are able to return a list of processes remotely are server 2003 Standard Edition with SP 1.
The target machine that does not return a list of processes remotely is server 2003 R2 Standard Edition SP2.
What would prevent me from getting a list of processes from a remote machine using powershell?
It turns out the machine that was returning the error did not have the Remote Registry service started. Once I started this service the "Couldn't connect to remote machine" error went away. This blog post helped me find the solution http://sebastienlachance.com/post/ProcessGetProcesses-common-errors.aspx
I think it uses WMI, so if the service isn't running, that would do it. Can you execute Get-WMIObject queries against those PCs at all?