If there is a powershell script to use a scheduled task to run, but powershell script is not "double-clicking" on it to open, then how to run it?
difficulty:
0 Some rights fails to load script
1 How to perform .ps1 file
2 Scheduled Tasks does not support direct input in the name of the program (such as powershell.exe), you must enter their spelling
3 If .ps1 file using the $ pwd (current working directory), how to set up so that $ pwd is required for the current directory
4 execute permissions problem
Solving steps:
0 create a shortcut, enter content powershell.exe
1 Create a scheduled task, and then open the Actions tab, as shown below
2 "program or script" in selecting the shortcut you just created, then this column will automatically appear the true path powershell program
3 "add parameter" in the input, xxxxxxx.ps1 represent ps1 file. This would solve the difficult one.
-File "xxxxxxx.ps1"
4 "starting" where you want to enter the working directory. 3 to resolve the difficulties.
Permissions issue:
Sometimes the script can not run, because some rights issues, such as
Could not load file ****. Ps1, because prohibits execution of the script in this system. For more information, see "get-help about_signing".
Location Line: Character 1: 17
+ D:\Learn\Run.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
See "get-help about_signing":
Solving steps:
1 Run as administrator Powershell
2 run set-ExecutionPolicy RemoteSigned and select yes