繁体   English   中英

通过任务计划程序的 Powershell 脚本不使用参数

[英]Powershell Script via Task Scheduler Not Working with Arguments

我希望你们今天能帮助我。 我不是 PowerShell 的专家,我只是用它来自动化一些任务,让生活更轻松。 我试图自动化的一件事是每天向那些密码将在 14 天内到期的员工发出密码提醒。 我编写的脚本 (NewPasswordChange.ps1) 在我通过 PowerShell 运行时可以完美运行,但在放入 Task Scheduler 时无法运行。 请让我知道我做错了什么。

操作:启动程序程序/脚本: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe

添加参数: -File 'NewPasswordChange.ps1' -smtpServer 'COMPANY-com.mail.protection.outlook.com' -expireInDays '14' -from 'IT Support it_support@COMPANY.com' -Logging -LogPath 'c:\\logFiles '

只有 powershell 理解单引号。 例如,当从常规命令行'IT Support it_support@COMPANY.com' ,将被解释为 3 个参数:

  1. 'IT
  2. Support
  3. it_support@COMPANY.com'

改用双引号:

-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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM