forked from fsprojects/FAKE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPsExecHelper.fs
23 lines (21 loc) · 1.04 KB
/
PsExecHelper.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/// Contains functions for working with Sysinternals PsExec
module Fake.PsExecHelper
let private formatArgs host username password exe inputs =
sprintf @"\\%s -u %s -p %s ""%s"" %s" host username password exe inputs
/// Use Sysinternals PsExec to execute a process on a remote machine.
/// ## Parameters
///
/// - `host` - The hostname of the machine to connect to.
/// - `username` - A username valid for connecting to the remote machine.
/// - `password` - The cleartext password of the given user.
/// - `exe` - The path to the file that is to be executed.
/// - `inputs` - The command-line arguments to pass to the remote process.
/// - `timeOut` - The timeout for PsExec.
let execRemote host username password exe inputs timeout =
let args = formatArgs host username password exe inputs
let exitCode =
ExecProcess (fun info ->
info.FileName <- "PsExec.exe"
info.Arguments <- args) timeout
if exitCode <> 0
then failwithf "Failed to execute %s as user %s on host %s with args %s" exe username host inputs