Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote powershell doesn't return any data #49

Closed
marcoliviernoel opened this issue Nov 5, 2020 · 1 comment
Closed

Remote powershell doesn't return any data #49

marcoliviernoel opened this issue Nov 5, 2020 · 1 comment
Assignees

Comments

@marcoliviernoel
Copy link

Hello,

I know this project is no longer supported but I am taking a chance because we need help and this project is the most promising solution to meet our needs. We tried several different ways but it seems that when we execute the commands in command prompt, everything works perfectly but when we try the same commands in php, we don't get any data, not even an error message.

$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @("*USER*",(ConvertTo-SecureString -String "*PASSWORD*" -AsPlainText -Force))

$session = New-PSSession -ComputerName "*SERVER*" -UseSSL -Credential $cred -Authentication CredSSP

Invoke-command -ComputerName "*SERVER*" -UseSSL -Credential $cred -Authentication CredSSP -ScriptBlock { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; Get-Mailbox|select alias }

In my examples, I have obviously replaced the sensitive values but in my execution I use the right values.

Do you have any idea why the code doesn't run the same in both environments? We are on Windows and use WAMP Server.

@merlinthemagic
Copy link
Owner

merlinthemagic commented Nov 11, 2020

I dont even have a windows lab anymore, otherwise i would plug it in to help you figure out whats up.

You store the session $var but you are not using it to invoke the next command. I'm missing something... However it appears you are trying to invoke a command on a remote server.

Regardless, The main reason MTS for Windows is not viable is that obtaining remote shells in Powershell mostly means spawning new processes without the ability to hook into them without heavy reliance on the window manager, which we dont have in a CLI only session.

Thats a long way of saying, its likely your command spawns a new PID and current process exits with an empty string return and no error code. But we just cannot hook into that new process.

(There is another project called MHIT that relies on Xvfb, Xte and xClip, which allows you to RDP from a Linux box to Windows and invoke commands on a windows desktop/Powershell environment. Its not public cuz documentation is a mess, but maybe it solves your issue?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants