• Hi,

    User Joie Andrew is right, you are looking for the -File parameter instead of the -Command parameter when you are pointing to a script file. If you would like to use the -Command parameter, then you have to type the command(s) right in there using the curly brackets, and separating each command with a semicolon. e.g.

    powershell.exe -Command {Write-Host "TEST" | Out-File -FilePath "C:\file.txt"; Start-Process -FilePath notepad.exe;}

    Which version of PoSh do you have? Is it 3.0?

    Starting from PowerShell 3.0 there is a cmdlet under the name of Send-MailMessage, if this is your case, you could ease your code by switching it with this cmdlet.

    I would strongly suggest to use the -NoProfile and -NonInteractive in order to avoid loading custom scripts (profiles) and the -NonInteractive switch is used to do not open a PoSh window, in this case it will work as a background process.

    As you might know, these parameters are temporary, they only last during the session, so after the session is closed, the configuration is gone too. If after retesting your issue with my previous suggestions did not help, I would ask you to additionally add to the start parameters the -ExecutionPolicy and set it with the value "Bypass", so we can be sure you are not having an execution policy misconfiguration (script origin[/url]).

    For more about information about PowerShell start parameters, please visit this LINK