Skip to content

Instantly share code, notes, and snippets.

@jetstreamin
Created July 9, 2015 17:17
Show Gist options
  • Save jetstreamin/97b581928dde9ebd3d95 to your computer and use it in GitHub Desktop.
Save jetstreamin/97b581928dde9ebd3d95 to your computer and use it in GitHub Desktop.
PowerShell in a Batch File
code = {
#iterate numbers 1 through 10
1..10 | foreach-object {
# just output them
"Current output:"
$_
}
}
Then use this PowerShell command to get the encoded version:
[convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($code))
Then copy/paste the output of the command to your batch file:
powershell.exe -EncodedCommand DQAKAAkAIwBpAHQAZQByAGEAdABlACAAbgB1AG0AYgBlAHIAcwAgADEAIAB0AGgAcgBvAHUAZwBoACAAMQAwAA0ACgAJADEALgAuADEAMAAgAHwAIABmAG8AcgBlAGEAYwBoAC0AbwBiAGoAZQBjAHQAIAB7AA0ACgAJACMAIABqAHUAcwB0ACAAbwB1AHQAcAB1AHQAIAB0AG
gAZQBtAA0ACgAJACIAQwB1AHIAcgBlAG4AdAAgAG8AdQB0AHAAdQB0ADoAIgANAAo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment