I need to run a PS script on a remote machine, am doing as in the below code.
Process psExecer = new Process
{
StartInfo =
{
UseShellExecute = false,
CreateNoWindow = false,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = @"c:\PsTools\PsExec.exe",
Arguments = @"c:\windows\System32\cmd.exe /k c:\windows\System32\WindowsPowerShell\v1.0\powershell.exe E:\Scripts\SetUP.ps1 -u super -p Pass -s"
}
};
psExecer.Start();
psExecer.WaitForExit();
Thread.Sleep(5000);
problem is that script has some sharepoint cmdlets and it has to load sharepoint PSSnapin. Script runs properly only when its run in 64 bit image of Powershell.
When i tried to run using PSTool, PSTool always ends up invoking 32 bit PowerShell from %windir%\SysWoW64 folder, even when i explicitly mentioned the path as shown in the code.
Why is it so, what is the solution to my problem
Regards, Jeez
cmdthen get that to loadpowershell, rather than runningpowershelldirectly?System32. Can you update your question to make sure there's no confusion...?