Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING

This crate was built in a short time for internal use. There are NO GUARANTEES MADE to security against command injection or other vulnerabilities. The crate was NOT AUDITED and should NEVER BE USED in externally accessible projects or with untrusted input.

Don't complain later that I didn't warn you!

powershell

powershell provides a Rust wrapper for Windows PowerShell. Command arguments are transferred as JSON, the final output is deserialized with Serde, and intermediate command results can be passed to later commands without converting them to text.

use powershell::{Outcome, Redact, powershell};

let sequence = powershell! {
    Vec<String>;
    @services = "Get-Service" {
        "Name" => Redact(vec!["ssh-agent", "WinRM"]),
    }
    "Select-Object" {
        "InputObject" => @services,
        "ExpandProperty" => "Name",
    }
};

match sequence.run()? {
    Outcome::Success(names) => println!("{names:?}"),
    Outcome::Failure(error) => eprintln!("PowerShell failed: {error}"),
}
# Ok::<(), powershell::errors::PowershellError>(())

The Redact wrapper only affects Debug and Display output. The original value is still serialized and sent to PowerShell.

Runtime requirements

Execution currently requires PowerShell 7 installed at its default 64-bit Windows path (C:\Program Files\PowerShell\7\pwsh.exe). Constructing, serializing, and formatting sequences does not invoke PowerShell.

License

This project is licensed under the GNU Affero General Public License v3.0.

About

A PowerShell Wrapper for Rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages