Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Arguments:
- UserName = Nothing
- Password = Nothing
- RemoteMachineName = "CurrentMachineName"
- PathBashFile = "Path/To/My/Local/Script.ps1"
- Params = "parameter1"
- Arguments:
- UserName = "MyUsername"
- Password = "MyPassword"
- RemoteMachineName = "RemoteMachineName"
- PathBashFile = "Path/To/My/Local/Script.ps1"
- Params = "parameter1"
- outParams("processId") = Nothing
- outParams("returnValue") = 8
- Try
- connOptions = New ConnectionOptions()
- connOptions.Username = UserName
- connOptions.Password = Password
- connOptions.Impersonation = ImpersonationLevel.Impersonate
- connOptions.Authentication = Management.AuthenticationLevel.PacketPrivacy
- managementPath = New ManagementPath("\" & RemoteMachineName & "rootcimv2:Win32_Process")
- Scope = New ManagementScope(managementPath, connOptions)
- Scope.Connect()
- objectGetOptions = New ObjectGetOptions()
- processClass = New ManagementClass(Scope, New ManagementPath("rootcimv2:Win32_Process"), objectGetOptions)
- inParams = processClass.GetMethodParameters("Create")
- inParams("CommandLine") = "cmd.exe /c powershell """ & PathBashFile & """ " & params
- inParams("CurrentDirectory") = workingDirectoryPath
- outParams = processClass.InvokeMethod("Create", inParams, Nothing)
- MsgBox(outParams("processId") & " " & outParams("returnValue"))
- Catch ex As Exception
- Throw New Exception("[ExecuteRemoteBashFile] " & ex.Message)
- End Try
Add Comment
Please, Sign In to add comment