ExecuteCommand(Directory.GetCurrentDirectory & "\psexec \\myservername
-u username-p passsword
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe")
Public Sub ExecuteCommand(ByVal Command As String)
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
ProcessInfo = New ProcessStartInfo("cmd.exe", "/K " & Command)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = True
Process = Process.Start(ProcessInfo)
End Sub
This is what I can see after launching powershell on my local machine when connected to my remote desktop
![enter image description here]()
And If I add the path of the file to execute this is how it looks like without any execution
ExecuteCommand(Directory.GetCurrentDirectory &"\psexec \\myservername
-u username-p passsword
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe D:\FreedSpace.ps1")
![enter image description here]()
After launching it I need to go to D:\
and there I have myscript.ps1
where I need to execute that script using powershell.
And the powershell versions on my local system as well as remote desktop are using v1.0