-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper function to execute Sysinternals PsExec
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |