【发布时间】:2018-12-09 09:33:00
【问题描述】:
当我尝试使用以下 PowerShell 命令读取此 url 时,我无法打开页面
Start-Process "iexplore.exe" "https://sitename//odata/ScheduledJobs?$format=json&$expand=Application($select=Id,Name,AssetId;$expand=Asset($select=Id,Name)),JobType,JobInstances($filter=StartTime+eq+null;$orderby=NextRunTime+asc;$top=1),CompletedJobs($orderby=StartTime+desc;$top=1;$expand=State;$select=Id,StateId,StartTime,EndTime)&$top=20&$orderby=ScheduleStart&$filter=Enabled+eq+true&$count=true"
Get-Process | Out-File -filepath C:\Users\S.Papolu\Downloads\ScheduledJobs1.json
如何在 IE 中打开该 url 并下载 json 输出?
请帮助我,感谢您的帮助,请发布代码
【问题讨论】:
-
Start-Process启动一个进程和一个 IE 实例。它不会读取页面上的数据。你应该使用Invoke-WebRequest或Invoke-RestMethod来做到这一点。获取数据后,在使用Out-File之前将其通过管道传输到ConvertTo-Json。
标签: json powershell odata powershell-2.0 powershell-3.0