powershell 计划任务 定时任务 如何调用get接口

1. 新增一个.ps1文件
1
2
3
4
5
6
7
8
9
10
11
12
# 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
posted @   iDEAAM  阅读(48)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
历史上的今天:
2016-07-18 关闭注册表编辑器,重新启动计算机后生效。这样资源管理器重启后就不会自动重启了。
点击右上角即可分享
微信分享提示