Make batch file with powershell script

旧巷老猫 提交于 2019-12-04 17:16:23

Remove powershell.exe from the file and save it as .ps1 then create a .bat file and write powershell.exe -file myscript.ps1

Bat file:

powershell.exe -file myscript.ps1

myScript.ps1:

$user="username@gamil.com"
$pass=cat I:\password.txt | convertto-securestring
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $pass
send-MailMessage -SmtpServer smtp.gmail.com -Credential $mycred -Usessl true -From 'username@gamil.com' -To 'usernametwo@gamil.com' -Subject 'failure Test'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!