I read a ton of articles on this and a bunch of posts here, tried all the suggestions and not having any luck.<\/p>\n
I’m using a script that sends emails to people who’s passwords are about to expire from here: Link<\/a><\/p>\n Advertisement Close I self-signed it so I don’t need to bypass the execution policy.<\/p>\nI have powershell.exe as the target. (I had the full path before also)<\/p>\nAs arguments I have: C:\\scripts\\PwdChangeNotification.ps1 -smtpServer -ca.mail.protection.outlook.com -expireInDays 10 -from \"IT Support <<\/strong><\/em>@.ca>\" -Logging -LogPath c:\\logFiles -reportTo \"<\/strong><\/em>@<\/strong>*.ca\"<\/p>\n(*'s is just to hide personal info)<\/p>\nWhen I paste that line as-is into powershell it executes with no issue.<\/p>\nwhen I run it from task scheduler I get: “powershell.exe” with return code 2147942401. (aka F** you from Microsoft-have a pleasant day)<\/p>\nI tried:<\/p>\n-Command &\" ‘C:\\scripts\\PwdChangeNotification.ps1’ -smtpServer -ca.mail.protection.outlook.com -expireInDays 10 -from \"IT Support <<\/strong><\/em>@.ca>\" -Logging -LogPath c:\\logFiles -reportTo \"<\/strong><\/em>@<\/strong>*.ca\" \"<\/p>\nI also tried the -File option but had no luck either.<\/p>\nI’m starting to think it will be easier to put it in a batch file and then run that via task scheduler at this point. Why is something so easy so hard to get working?!<\/p>","upvoteCount":2,"answerCount":6,"datePublished":"2018-09-04T16:54:22.000Z","author":{"@type":"Person","name":"cecilduplessis2","url":"https://community.spiceworks.com/u/cecilduplessis2"},"acceptedAnswer":{"@type":"Answer","text":"
I self-signed it so I don’t need to bypass the execution policy.<\/p>\n
I have powershell.exe as the target. (I had the full path before also)<\/p>\n
As arguments I have: C:\\scripts\\PwdChangeNotification.ps1 -smtpServer -ca.mail.protection.outlook.com -expireInDays 10 -from \"IT Support <<\/strong><\/em>@.ca>\" -Logging -LogPath c:\\logFiles -reportTo \"<\/strong><\/em>@<\/strong>*.ca\"<\/p>\n(*'s is just to hide personal info)<\/p>\nWhen I paste that line as-is into powershell it executes with no issue.<\/p>\nwhen I run it from task scheduler I get: “powershell.exe” with return code 2147942401. (aka F** you from Microsoft-have a pleasant day)<\/p>\nI tried:<\/p>\n-Command &\" ‘C:\\scripts\\PwdChangeNotification.ps1’ -smtpServer -ca.mail.protection.outlook.com -expireInDays 10 -from \"IT Support <<\/strong><\/em>@.ca>\" -Logging -LogPath c:\\logFiles -reportTo \"<\/strong><\/em>@<\/strong>*.ca\" \"<\/p>\nI also tried the -File option but had no luck either.<\/p>\nI’m starting to think it will be easier to put it in a batch file and then run that via task scheduler at this point. Why is something so easy so hard to get working?!<\/p>","upvoteCount":2,"answerCount":6,"datePublished":"2018-09-04T16:54:22.000Z","author":{"@type":"Person","name":"cecilduplessis2","url":"https://community.spiceworks.com/u/cecilduplessis2"},"acceptedAnswer":{"@type":"Answer","text":"
(*'s is just to hide personal info)<\/p>\n
When I paste that line as-is into powershell it executes with no issue.<\/p>\n
when I run it from task scheduler I get: “powershell.exe” with return code 2147942401. (aka F** you from Microsoft-have a pleasant day)<\/p>\n
I tried:<\/p>\n
-Command &\" ‘C:\\scripts\\PwdChangeNotification.ps1’ -smtpServer -ca.mail.protection.outlook.com -expireInDays 10 -from \"IT Support <<\/strong><\/em>@.ca>\" -Logging -LogPath c:\\logFiles -reportTo \"<\/strong><\/em>@<\/strong>*.ca\" \"<\/p>\nI also tried the -File option but had no luck either.<\/p>\nI’m starting to think it will be easier to put it in a batch file and then run that via task scheduler at this point. Why is something so easy so hard to get working?!<\/p>","upvoteCount":2,"answerCount":6,"datePublished":"2018-09-04T16:54:22.000Z","author":{"@type":"Person","name":"cecilduplessis2","url":"https://community.spiceworks.com/u/cecilduplessis2"},"acceptedAnswer":{"@type":"Answer","text":"
I also tried the -File option but had no luck either.<\/p>\n
I’m starting to think it will be easier to put it in a batch file and then run that via task scheduler at this point. Why is something so easy so hard to get working?!<\/p>","upvoteCount":2,"answerCount":6,"datePublished":"2018-09-04T16:54:22.000Z","author":{"@type":"Person","name":"cecilduplessis2","url":"https://community.spiceworks.com/u/cecilduplessis2"},"acceptedAnswer":{"@type":"Answer","text":"