Convert PowerShell script into non-readable format

后端 未结 3 1520
时光说笑
时光说笑 2020-12-30 16:36

I have a PowerShell script which installs a patch (contains set of files to be added) on a customer machine. For this, I have created a batch file which executes this PowerS

3条回答
  •  攒了一身酷
    2020-12-30 17:11

    You can convert the script to Base64 encoding, so that it's not immediately readable. To convert a PowerShell script file to a Base64 String, run the following command:

    $Base64 = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('c:\path\to\script file.ps1'));
    

    To launch the Base64-encoded script, you can call PowerShell.exe as follows:

    powershell.exe -EncodedCommand 
    

    For example, the following command:

    powershell.exe -EncodedCommand VwByAGkAdABlAC0ASABvAHMAdAAgAC0ATwBiAGoAZQBjAHQAIAAiAEgAZQBsAGwAbwAsACAAdwBvAHIAbABkACEAIgA7AA==
    

    Will return the following results:

    Hello, world!
    

提交回复
热议问题