Powershell script does not run via Scheduled Tasks

后端 未结 18 942
南方客
南方客 2020-12-02 23:12

I have a small script on my Domain Controller that is setup to email me via SMTP about the latest Security Event 4740.

The script, when executed manually, will run a

18条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 23:43

    NOTE: Please ensure that you select Create a Basic task Action and NOT the Create Task Action.

    I found the following solution:

    1) Make powershell.exe run as administrator for this

    1. right-click on the powershell.exe icon
    2. click on properties under the shortcut key menu
    3. click on the advance button; check that "run as administrator" is checked.

    2) in the task scheduler window under the action pane add the following script as a new command

    %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -ExecutionPolicy Bypass -noexit -File "C:\ps1\BackUp.ps1"
    

提交回复
热议问题