在 PowerShell 中迭代从 Web 服务返回的数据
我编写了一个 PowerShell 脚本来使用新的 PS 2.0 命令调用 Web 服务。我想知道如何迭代 $events
结果。该代码用于返回数据,我只是不确定结果数据类型是什么或如何迭代它。
这是代码:
#connect to web service
$ap = New-WebServiceProxy -Uri http://cantreallygiveyouthis/api/services/data?wsdl
#specify event params
$params = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3ices_AlarmPointWebService_wsdl.EventSearchParameters
$params.datasource = "runtime"
$params.startDate = "01/09/2011 3:00:00 PM"
$params.endDate = "01/09/2011 3:15:00 PM"
#call web service
$events = $ap.FindEvents("username", "pass", "", "", "", ":)", $params)
I've written a PowerShell script to call a Web Service using the new PS 2.0 commands. I would like to know how to iterate the $events
result. The code works in returning data, I'm just not sure what the result data type is or how to iterate thru it.
Here's the code:
#connect to web service
$ap = New-WebServiceProxy -Uri http://cantreallygiveyouthis/api/services/data?wsdl
#specify event params
$params = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3ices_AlarmPointWebService_wsdl.EventSearchParameters
$params.datasource = "runtime"
$params.startDate = "01/09/2011 3:00:00 PM"
$params.endDate = "01/09/2011 3:15:00 PM"
#call web service
$events = $ap.FindEvents("username", "pass", "", "", "", ":)", $params)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显而易见的选择是
$events | Get-Member
或$events[0] | Get-Member
了解您可以使用哪些内容。$events[0].Gettype()
也很有用。The obvious choice would be
$events | Get-Member
or$events[0] | Get-Member
to find out what's available to you.$events[0].Gettype()
can be useful as well.