I have a powershell script, which works, since I have executed it manually on the server. But I cant get it to work from the C# code on one of our servers. It does work on two other computers, with the code, but not on the server where I need to execute it.
The code that executes the script:
var process = new Process();
process = Process.Start("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\Powershell.exe", "C:\\CC\\Script\\script.ps1");
I have tried with other variations but we are running PowerShell v1.0 and it doesnt support the solutions: https://blogs.msdn.microsoft.com/kebab/2014/04/28/executing-powershell-scripts-from-c/
Since the code works on two computer but not on the server where we need to use it, I checked the Execution Policy and it was "RemoteSigned" on all of them.
Any ideas what else it could be? Would it make any difference with another set of code and do you have any good examples of what code I could use instead, for PowerShell v1.0? Any other policies that could make the difference?
Thnx in advance