Skip to content

Instantly share code, notes, and snippets.

@spy86
Created January 21, 2019 21:14
Show Gist options
  • Select an option

  • Save spy86/ed0a7912e92d30164d78c398403e43dc to your computer and use it in GitHub Desktop.

Select an option

Save spy86/ed0a7912e92d30164d78c398403e43dc to your computer and use it in GitHub Desktop.
Encode powershell script
$command = 'send-mailmessage -from -to -subject "$env:computername has been restarted" -body "The server $env:computername has recently restarted. If this was unexpected please log into the server and check the cause as soon as possible." -smtpserver '
$bytes = [system.text.encoding]::Unicode.GetBytes($command)
$encodedCommand = [convert]::tobase64string($bytes)
echo $encodedCommand > encodedtext.txt
notepad encodedtext.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment