powershell/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::process::{Command, Output};

use base64::prelude::*;

pub fn execute(command: impl AsRef<str>) -> Output {
    Command::new("powershell")
        .arg("-NoLogo")
        .arg("-NoProfile")
        .arg("-NonInteractive")
        .arg("-WindowStyle")
        .arg("Hidden")
        .arg("-ExecutionPolicy")
        .arg("Bypass")
        .arg("-EncodedCommand")
        .arg(
            BASE64_STANDARD.encode(bytemuck::cast_slice::<u16, u8>(
                command
                    .as_ref()
                    .encode_utf16()
                    .collect::<Vec<u16>>()
                    .as_slice(),
            )),
        )
        .output()
        .unwrap()
}