任务powershell:你如何运行计划任务?

时间:2022-05-12 02:31:55

How do you run a scheduled task with Quest powershell snap in?

如何使用Quest powershell snap in运行计划任务?

2 个解决方案

#1


2  

You would schedule PowerShell.exe, and use one of its command-line parameters to specify the script to run. At the start of that script, add:

您将安排PowerShell.exe,并使用其命令行参数之一指定要运行的脚本。在该脚本的开头,添加:

Add-PSSnapin Quest.ActiveRoles.ADManagement

That will load the snapin for that script, and then execute whatever else is in the script.

这将加载该脚本的snapin,然后执行脚本中的任何其他内容。

(BTW, this would be the case for any script that needs one or more extra snapins.)

(顺便说一下,任何需要一个或多个额外snapin的脚本都是这种情况。)

#2


0  

Another option would be to create a console file (using Export-Console - which will create a *.psc1 ) and adding -PSConsoleFile YourConsole.psc1 to your powershell.exe command line.

另一种选择是创建一个控制台文件(使用Export-Console - 它将创建一个* .psc1)并将-PSConsoleFile YourConsole.psc1添加到您的powershell.exe命令行。

#1


2  

You would schedule PowerShell.exe, and use one of its command-line parameters to specify the script to run. At the start of that script, add:

您将安排PowerShell.exe,并使用其命令行参数之一指定要运行的脚本。在该脚本的开头,添加:

Add-PSSnapin Quest.ActiveRoles.ADManagement

That will load the snapin for that script, and then execute whatever else is in the script.

这将加载该脚本的snapin,然后执行脚本中的任何其他内容。

(BTW, this would be the case for any script that needs one or more extra snapins.)

(顺便说一下,任何需要一个或多个额外snapin的脚本都是这种情况。)

#2


0  

Another option would be to create a console file (using Export-Console - which will create a *.psc1 ) and adding -PSConsoleFile YourConsole.psc1 to your powershell.exe command line.

另一种选择是创建一个控制台文件(使用Export-Console - 它将创建一个* .psc1)并将-PSConsoleFile YourConsole.psc1添加到您的powershell.exe命令行。