小编mar*_*rio的帖子

如何在任务计划程序上执行PowerShell脚本?

我试图执行我的Powershell脚本每5分钟运行一次.我尝试使用Windows 7的任务计划程序来运行它,但它在记事本上打开我的脚本并且不会在我的数据库中插入任何内容

下面是我的Powershell V-2.0脚本.我不确定我的代码中是否有错误(我怀疑)或者我是否可以将其包含在我的脚本中以便每隔5分钟运行一次,从早上9点到晚上9点.

这是我如何安排它:

General
--------
Run only when user is logged on

Triggers
--------
Trigger: at 8h56am every day- 
Details: After triggered, repeat every 5 minutes indefinitely
Status: Enabled

Actions
-------
Action: Start a program
Details: Path to the script
Run Code Online (Sandbox Code Playgroud)

提前致谢!

POWERSHELL(不包括连接):

function ping_getUser{

#ping each computer if online, obtain information about the local hard drives only
TRY{
    foreach($workstation in $workstation_list){

        $command = $connection.CreateCommand();
        $command.Connection  = $connection;
        $command.CommandText = "INSERT INTO workstation_userlogged
                                (username,hostname,online)
                                VALUES (@username,@hostname,@status)";

        ### ============================================================= 
        ### …
Run Code Online (Sandbox Code Playgroud)

mysql powershell powershell-ise powershell-2.0

1
推荐指数
1
解决办法
2810
查看次数