I am using a script to send emails on my machine , the script is a sh script and i need to execute automatically that script via another batch script , the problem is when i copy past the code on my Powershell command directly the code works fine the email will be sent , but then when I try to use a script to run it it always fail : This is my code for email :
$EmailFrom = “whatever@gmail.com”
'$EmailTo = “whatever@gmail.com”
'$Subject = “helooo2o”
$Body = “test test test”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“whatever@gmail.com”, “pwd”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
it works fine when i put it directly on CMD then Powershell it works but when i use this script it won't work :
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -command 'C:\Users\user1\Desktop\test.sh'
also when I use PowerShell with the command : Bash test.sh it shows me this :
bash /test.sh: cannot execute binary file
Can you guys help me i need to run automatically this script with a batch script thank you in advance .