1. 新增一个.ps1文件
# Define the URI $uri = "http://xxx.com/api/test" # Invoke the REST method $response = Invoke-RestMethod -Uri $uri # Output the response $response # Exit the script exit
2. 在windows计划任务新增一个任务
2.1. 配置操作:
在任务向导中,选择“启动程序”作为操作类型,并指定PowerShell可执行文件路径(如C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe),以及您的.ps1脚本文件的路径。2.2. 配置参数:在操作设置中,将您的.ps1脚本文件作为参数传递给PowerShell可执行文件。例如:-File "C:\path\to\your\script.ps1"。
-WindowStyle Hidden参数来隐藏PowerShell窗口
powershell.exe -WindowStyle Hidden -File C:\path\to\your\script.ps1











