Remote Powershell script causes Selenium to timeout - powershell

When I use Invoke-Command from a Powershell script to run an .exe that uses Selenium Chromedriver, the execution of my .exe hangs until I get a timeout exception.
I have tried running the .exe with a local Powershell command, and it works just fine every time. It is only when I use Invoke-Command that the .exe stops working. Is there any way to actually run powershell scripts remotely, without Invoke-Command because Invoke-Command doesn't seem to be doing what I want it to.
I've also tried to -Wait the process of the .exe but it still hangs.

Related

installing file on remote machine with GUI

whenever an .exe file is executed on remote machine with help of pssession and invoke-command with start-process..
it the execuable runs in background , i am able to see the process in task manager but cpu alloted to that process is 0% and also it keeps running.
i want to pop up GUI of executable file on remote machine whenever i run script.
i tried..
1)
Invoke-Command -ScriptBlock {Start-Process -Wait -FilePath 'C:\Documents and Settings\user\Desktop\scripts\dbsetup_trial.exe' -ArgumentList '/S' -PassThru -Verb runas}
2) by enetring in PSsession, i tried executing exe, bt result was same.
please help me out.
i need to install file , if silent installation is option it should install file silently or just pop the window of executable and return back.
You cannot invoke a GUI on a remote system's interactive session via PowerShell. PowerShell remote sessions are unable to interact with other sessions, especially the logged-on user session(s).
psexec can do this, but the better way to do this is to run a silent/unattended install if it's an option with that application installer. We can't answer that because we don't know what that installer is or how it's made.

Execute a Remote 32 Bit PSSession with elevated rights

So I'm trying to get a script to run a script from a server remotely on another server. This session has to be 32 bit because of a cmdlet. And the script has to be run as admin.
I've tried this:
Invoke-Command -ComputerName isg108-81 -FilePath C:\inetpub\scrip\ConvertAppvPackages.ps1 -ConfigurationName microsoft.powershell32 -credentials Admin
So this starts the 32 bit version of powershell, but as soon as the script gets to the part where it needs elevated rights the shell tells me:
You must run this cmdlet using a Windows PowerShell elevated command prompt . To run
an elevated command prompt, right-click the Windows PowerShell or Command Prompt Start
menu object that you are using to start your Windows PowerShell sessions, and then
Select Run as administrator.
Anybody got any ideas?
Thnx a lot for your help!
If the server is a 64 bit OS, you'll have to call the 32 bit powershell.exe. What if you Invoked the server to run the 32 exe and run the script? Since your invoking it the program won't show up and the script would have to output some file to see any results.
So it turned out that the ConverFrom-AppvLeagcyPackage cmdlet somehow is broken and can't be executed remotely. As a solution I used the program Psexec to run the script remotely, although it only works if you run it as the system user.
Thank you non the less for your help!

PowerShell: Starting the CLR Failed with HRESULT 8007000e

I'm getting the following error when running PowerShell scripts on a remote server:
Starting the CLR Failed with HRESULT 8007000e
This is basically how I'm running/calling the scripts:
On the local server I'm running a CMD script that calls a PowerShell script to create a remote session to a remote server. In the PowerShell script I also call a CMD script to run on the remote server like so:
$Script = [scriptblock]::create("cd $BuildPath | cmd.exe /c install.cmd $apptype")
The install.cmd script runs on the remote server and calls a PowerShell script that executes a series of tasks.
powershell ./Install.ps1 -BuildNum %BUILDNUM%
After the tasks are complete, the PowerShell script then calls another PowerShell script to run a separate series of tasks. This is when I hit the above error, when the second PowerShell script is called.
This is how the second PS1 script is called from the first PowerShell script:
powershell "& {. $BinToolsSrc\PostInstallValidation.ps1 -BuildNum $BuildNum -Test 'True'; Run-Validation -App $App -AppLoc $AppLoc -Env $Env:ENV -Site $Site -AppPool $AppPool -Config $Config -EnvConfig $EnvConfig -DllPath $DllPath}"
What usually causes the type of CLR error that I'm getting and how do I resolve it?
NOTE: I do not get this error when I run the install script locally on the remote server.
Thanks in advance!
UPDATE: Installing PowerShell 3 on the remote server seems to have solved the problem as it targets the .NET 4.0 runtime.
I too had the same problem because I have changed some path settings in my VScode unknowingly.
I have changed the settings to command prompt which works fine for me now...(This might not be the best solution though).screenshot

Start a program or filepath remotely

With XP machines and eventually win7 machines. I am trying to find a way to start a program remotely from the commandline or even powershell if possible. Right now we can kill tasks using the "taskkill" command, but there doesn't seem to be an easy way to start them without extra programs. I want to be able to do it without deploying anything. I tried that Psexec but that didnt work.
Invoke-Command -ComputerName server01 -ScriptBlock { yourprogram.exe }
Check out technet:
The Invoke-Command cmdlet runs commands on a local or remote computer and returns all output from the commands, including errors. With a single Invoke-Command command, you can run commands on multiple computers.
http://technet.microsoft.com/en-us/library/hh849719.aspx

Running remote scripts in powershell

I've successfully got winrm working and I'm able to run Enter-PSSession my-machine in the shell and subsequently enter commands. However, when I try to run a script that starts up a remote session, all subsequent calls are run on the local machine. For instance:
PS> test.ps1
Contents of test.ps1
Enter-PSSession remote-pcname
gc env:computername
prints out local-pcname instead of remote-pcname any idea why the script file is not honoring the remote session? It is definitely successfully connecting because when the script finishes I'm returned to the shell prompt of the remote machine.
The short answer is: Enter-PSSession is intended for interactive use. If you want to execute commands on a remote system from a script, use invoke-command.
A similiar thread on the Technet forums is here:
http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/90e92d4e-716b-4b4d-956f-d38645e5c035
For me it work as documented. Enter-PSSession start an interactive session, it's for interactive use.
So to execute a script you can use New-PSSession to create a session and Invoke-Command using the remote session you created with New-PSSession.