# This is the encoded command
# Essentially your code wrapped in a string
# This sends emails to your gmail account / easily changeable
$cmd = '$mailMessage = [System.Net.Mail.MailMessage]::new("from@gmail.com", "to@gmail.com")
$mailMessage.Subject = "Test Email From HTA"
$client = [System.Net.Mail.SmtpClient]::new("smtp.gmail.com", 587)
$credentials = [System.Net.NetworkCredential]::new("username", "userpassword")
$client.Credentials = $credentials
$client.EnableSsl = "True"
$client.Host = "smtp.gmail.com"
$client.Send($mailMessage)'
$bytes = [System.Text.Encoding]::Unicode.GetBytes($cmd)
$encodedCommand = [Convert]::ToBase64String($bytes)
# This is the base 64 string to pass to the encoded command in the HTML file
write-host $encodedCommand
Powershell script to get encode for HTA and pass to Powershell
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.