[英]Powershell Script via Task Scheduler Not Working with Arguments
I'm hoping you geniuses can help me out today.我希望你们今天能帮助我。 I'm not a savant with PowerShell, I only use it to automate some tasks to make life easier.
我不是 PowerShell 的专家,我只是用它来自动化一些任务,让生活更轻松。 The one thing I'm trying to automate is a daily password reminder to those employees whose password will be expiring within 14 days.
我试图自动化的一件事是每天向那些密码将在 14 天内到期的员工发出密码提醒。 The script I wrote (NewPasswordChange.ps1) works flawlessly when I run it via PowerShell, but will not run when put into Task Scheduler.
我编写的脚本 (NewPasswordChange.ps1) 在我通过 PowerShell 运行时可以完美运行,但在放入 Task Scheduler 时无法运行。 Please let me know what I'm doing wrong.
请让我知道我做错了什么。
Action: Start a program Program/Script: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe操作:启动程序程序/脚本: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe
Add Arguments: -File 'NewPasswordChange.ps1' -smtpServer 'COMPANY-com.mail.protection.outlook.com' -expireInDays '14' -from 'IT Support it_support@COMPANY.com' -Logging -LogPath 'c:\\logFiles'添加参数: -File 'NewPasswordChange.ps1' -smtpServer 'COMPANY-com.mail.protection.outlook.com' -expireInDays '14' -from 'IT Support it_support@COMPANY.com' -Logging -LogPath 'c:\\logFiles '
Only powershell understands the single-quotes.只有 powershell 理解单引号。 When used from a regular command line
'IT Support it_support@COMPANY.com'
for example will be interpreted as 3 arguments:例如,当从常规命令行
'IT Support it_support@COMPANY.com'
,将被解释为 3 个参数:
'IT
Support
it_support@COMPANY.com'
Use double quotes instead:改用双引号:
-File "NewPasswordChange.ps1" -SmtpServer "COMPANY-com.mail.protection.outlook.com" -ExpireInDays 14 -From "IT Support it_support@COMPANY.com" -Logging -LogPath "c:\logFiles"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.