Created
July 9, 2015 17:17
-
-
Save jetstreamin/97b581928dde9ebd3d95 to your computer and use it in GitHub Desktop.
PowerShell in a Batch File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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