Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Encode String and Execute with PowerShell

$
0
0

Summary: Learn how to encode a string into base64 and execute it with Windows PowerShell.

Hey, Scripting Guy! Question How can I encode a string into base64 and then run it via Windows PowerShell?

Hey, Scripting Guy! Answer Use these commands:

$string = {(Get-WindowsFeature).Where{$PSItem.Installed}}.ToString()

$encodedcommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($string))

powershell.exe -EncodedCommand $encodedcommand


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>