Windows powershell web服务hello world错误日志

Windows powershell web服务hello world错误日志,windows,powershell,scripting,malware,executionpolicy,Windows,Powershell,Scripting,Malware,Executionpolicy,我可以运行“hello world”脚本,但尝试运行此脚本: 这是一个政策问题吗?或者,脚本本身有问题吗 此外: 在我看来,这似乎是您正在调用的web服务的一个问题。它返回字符串“exception”。您的代码运行正常 导航到该站点并运行一个测试,我还收到一个异常返回。在我看来,您调用的web服务存在问题。它返回字符串“exception”。您的代码运行正常 导航到该站点并运行一个测试,我在那里也得到了一个异常。尝试运行此测试,但也得到了一个异常: PS:14:27:35>$quote=Invo

我可以运行“hello world”脚本,但尝试运行此脚本:

这是一个政策问题吗?或者,脚本本身有问题吗

此外:


在我看来,这似乎是您正在调用的web服务的一个问题。它返回字符串“exception”。您的代码运行正常


导航到该站点并运行一个测试,我还收到一个异常返回。

在我看来,您调用的web服务存在问题。它返回字符串“exception”。您的代码运行正常


导航到该站点并运行一个测试,我在那里也得到了一个异常。

尝试运行此测试,但也得到了一个异常:

PS:14:27:35>$quote=Invoke RestMethod-Uri”“-Method Get

PS:14:27:49>$quote.string

xmlns#text
---------
例外情况


PS:14:27:53>$quote.string.#text'

尝试运行此命令,但也出现异常:

PS:14:27:35>$quote=Invoke RestMethod-Uri”“-Method Get

PS:14:27:49>$quote.string

xmlns#text
---------
例外情况

PS:14:27:53>$quote.string.#text'

输出:

Microsoft Windows[版本10.0.14393]
(c) 2016年微软公司。版权所有。
C:\Users\thufir>cd桌面
C:\Users\thufir\Desktop>powershell-ExecutionPolicy RemoteSigned
Windows PowerShell
版权所有(C)2016年微软公司。版权所有。
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop>\foobar.ps1
类型名称:WebServiceProxy.GlobalWeather
名称成员类型定义
----                                 ---------- ----------
已处置事件System.EventHandler已处置(System.Object、System.EventArgs)
GetCitiesByCountry已完成事件WebServiceProxy.GetCitiesByCountryCompletedEventHandler GetCitiesByC。。。
GetWeatherCompleted事件WebServiceProxy.GetWeatherCompletedEventHandler GetWeatherCompleted(。。。
中止方法void Abort()
BeginGetCitiesByCountry方法System.IAsyncResult BeginGetCitiesByCountry(字符串CountryName,Syst。。。
BeginGetWeather方法System.IAsyncResult BeginGetWeather(字符串CityName,字符串CountryN。。。
CancelAsync方法void CancelAsync(System.Object userState)
CreateObjRef方法System.Runtime.Remoting.ObjRef CreateObjRef(类型requestedType)
Discover方法void Discover()
Dispose方法void Dispose(),void IDisposable.Dispose()
EndGetCitiesByCountry方法字符串EndGetCitiesByCountry(System.IAsyncResult asyncResult)
EndGetWeather方法字符串EndGetWeather(System.IAsyncResult asyncResult)
Equals方法bool Equals(System.Object obj)
GetCitiesByCountry方法字符串GetCitiesByCountry(字符串CountryName)
GetCitiesByCountryAsync方法void GetCitiesByCountryAsync(字符串CountryName),void GetCitiesByCo。。。
GetHashCode方法int GetHashCode()
GetLifetimeService方法系统。对象GetLifetimeService()
GetType方法类型GetType()
GetWeather方法字符串GetWeather(字符串CityName,字符串CountryName)
GetWeatherAsync方法void GetWeatherAsync(字符串CityName,字符串CountryName),void GetW。。。
InitializeLifetimeService方法系统。对象InitializeLifetimeService()
ToString方法字符串ToString()
AllowAutoRedirect属性bool AllowAutoRedirect{get;set;}
ClientCertificates属性系统。安全性。加密。X509Certificates.X509CertificateCollect。。。
ConnectionGroupName属性字符串ConnectionGroupName{get;set;}
容器属性System.ComponentModel.IContainer容器{get;}
CookieContainer属性System.Net.CookieContainer CookieContainer{get;set;}
凭据属性System.Net.ICredentials凭据{get;set;}
EnableDecompression属性bool EnableDecompression{get;set;}
预验证属性布尔预验证{get;set;}
Proxy Property System.Net.IWebProxy代理{get;set;}
RequestEncoding属性System.Text.Encoding RequestEncoding{get;set;}
站点属性System.ComponentModel.ISite站点{get;set;}
SoapVersion属性System.Web.Services.ProtocolVersion SoapVersion SoapVersion{get;s。。。
Timeout属性int Timeout{get;set;}
UnsafeAuthenticatedConnectionSharing属性bool UnsafeAuthenticatedConnectionSharing{get;set;}
Url属性字符串Url{get;set;}
UseDefaultCredentials属性bool UseDefaultCredentials{get;set;}
UserAgent属性字符串UserAgent{get;set;}
澳大利亚
阿彻菲尔德机场
澳大利亚
安伯利机场
澳大利亚
爱丽丝泉机场
澳大利亚
布里斯班机场
澳大利亚
库兰加塔机场
澳大利亚
凯恩斯机场
澳大利亚
查理维尔机场
澳大利亚
格莱斯顿
澳大利亚
长距离机场
澳大利亚
伊萨阿摩山
澳大利亚
莫麦凯
澳大利亚
奥基机场
澳大利亚
普罗瑟派恩机场
澳大利亚
罗克汉普顿机场
C:\Users\thufir\Desktop>
C:\Users\thufir\Desktop>powershell -ExecutionPolicy RemoteSigned
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> type .\stock.ps1
# Working example of how to use PowerShell (version >= 2) to access a web service.
$svc = New-WebServiceProxy –Uri ‘http://www.webservicex.net/stockquote.asmx?WSDL’

$svc | Get-Member  # Use Get-Member to discover the interface of a web service.
# Get stock quotes.
$svc.GetQuote(‘BA’)   # Boeing
$svc.GetQuote(‘AMZN’) # Amazon
$svc.GetQuote(‘SBUX’) # Starbucks
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\stock.ps1


   TypeName: Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vicex_net_stockquote_a
smx_WSDL.StockQuote

Name                                 MemberType Definition
----                                 ---------- ----------
Disposed                             Event      System.EventHandler Disposed(System.Object, System.EventArgs)
GetQuoteCompleted                    Event      Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes....
Abort                                Method     void Abort()
BeginGetQuote                        Method     System.IAsyncResult BeginGetQuote(string symbol, System.AsyncCallbac...
CancelAsync                          Method     void CancelAsync(System.Object userState)
CreateObjRef                         Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Discover                             Method     void Discover()
Dispose                              Method     void Dispose(), void IDisposable.Dispose()
EndGetQuote                          Method     string EndGetQuote(System.IAsyncResult asyncResult)
Equals                               Method     bool Equals(System.Object obj)
GetHashCode                          Method     int GetHashCode()
GetLifetimeService                   Method     System.Object GetLifetimeService()
GetQuote                             Method     string GetQuote(string symbol)
GetQuoteAsync                        Method     void GetQuoteAsync(string symbol), void GetQuoteAsync(string symbol,...
GetType                              Method     type GetType()
InitializeLifetimeService            Method     System.Object InitializeLifetimeService()
ToString                             Method     string ToString()
AllowAutoRedirect                    Property   bool AllowAutoRedirect {get;set;}
ClientCertificates                   Property   System.Security.Cryptography.X509Certificates.X509CertificateCollect...
ConnectionGroupName                  Property   string ConnectionGroupName {get;set;}
Container                            Property   System.ComponentModel.IContainer Container {get;}
CookieContainer                      Property   System.Net.CookieContainer CookieContainer {get;set;}
Credentials                          Property   System.Net.ICredentials Credentials {get;set;}
EnableDecompression                  Property   bool EnableDecompression {get;set;}
PreAuthenticate                      Property   bool PreAuthenticate {get;set;}
Proxy                                Property   System.Net.IWebProxy Proxy {get;set;}
RequestEncoding                      Property   System.Text.Encoding RequestEncoding {get;set;}
Site                                 Property   System.ComponentModel.ISite Site {get;set;}
SoapVersion                          Property   System.Web.Services.Protocols.SoapProtocolVersion SoapVersion {get;s...
Timeout                              Property   int Timeout {get;set;}
UnsafeAuthenticatedConnectionSharing Property   bool UnsafeAuthenticatedConnectionSharing {get;set;}
Url                                  Property   string Url {get;set;}
UseDefaultCredentials                Property   bool UseDefaultCredentials {get;set;}
UserAgent                            Property   string UserAgent {get;set;}
exception
exception
exception


PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\hello.ps1
hi
Cannot convert value "Data Not Found" to type "System.Xml.XmlDocument". Error: "The specified node cannot be inserted
as the valid child of this node, because the specified node is the wrong type."
At C:\Users\thufir\Desktop\hello.ps1:8 char:1
+ [xml]$response = $proxy.GetWeather("Tampa", "United States")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastToXmlDocument

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> type .\hello.ps1



echo "hi"


$proxy = New-WebServiceProxy -Uri http://www.webservicex.net/globalweather.asmx?WSDL
[xml]$response = $proxy.GetWeather("Tampa", "United States")
$response.CurrentWeather | Format-List

PS C:\Users\thufir\Desktop>
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\thufir>cd Desktop

C:\Users\thufir\Desktop>powershell -ExecutionPolicy RemoteSigned
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> .\foobar.ps1


   TypeName: WebServiceProxy.GlobalWeather

Name                                 MemberType Definition
----                                 ---------- ----------
Disposed                             Event      System.EventHandler Disposed(System.Object, System.EventArgs)
GetCitiesByCountryCompleted          Event      WebServiceProxy.GetCitiesByCountryCompletedEventHandler GetCitiesByC...
GetWeatherCompleted                  Event      WebServiceProxy.GetWeatherCompletedEventHandler GetWeatherCompleted(...
Abort                                Method     void Abort()
BeginGetCitiesByCountry              Method     System.IAsyncResult BeginGetCitiesByCountry(string CountryName, Syst...
BeginGetWeather                      Method     System.IAsyncResult BeginGetWeather(string CityName, string CountryN...
CancelAsync                          Method     void CancelAsync(System.Object userState)
CreateObjRef                         Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Discover                             Method     void Discover()
Dispose                              Method     void Dispose(), void IDisposable.Dispose()
EndGetCitiesByCountry                Method     string EndGetCitiesByCountry(System.IAsyncResult asyncResult)
EndGetWeather                        Method     string EndGetWeather(System.IAsyncResult asyncResult)
Equals                               Method     bool Equals(System.Object obj)
GetCitiesByCountry                   Method     string GetCitiesByCountry(string CountryName)
GetCitiesByCountryAsync              Method     void GetCitiesByCountryAsync(string CountryName), void GetCitiesByCo...
GetHashCode                          Method     int GetHashCode()
GetLifetimeService                   Method     System.Object GetLifetimeService()
GetType                              Method     type GetType()
GetWeather                           Method     string GetWeather(string CityName, string CountryName)
GetWeatherAsync                      Method     void GetWeatherAsync(string CityName, string CountryName), void GetW...
InitializeLifetimeService            Method     System.Object InitializeLifetimeService()
ToString                             Method     string ToString()
AllowAutoRedirect                    Property   bool AllowAutoRedirect {get;set;}
ClientCertificates                   Property   System.Security.Cryptography.X509Certificates.X509CertificateCollect...
ConnectionGroupName                  Property   string ConnectionGroupName {get;set;}
Container                            Property   System.ComponentModel.IContainer Container {get;}
CookieContainer                      Property   System.Net.CookieContainer CookieContainer {get;set;}
Credentials                          Property   System.Net.ICredentials Credentials {get;set;}
EnableDecompression                  Property   bool EnableDecompression {get;set;}
PreAuthenticate                      Property   bool PreAuthenticate {get;set;}
Proxy                                Property   System.Net.IWebProxy Proxy {get;set;}
RequestEncoding                      Property   System.Text.Encoding RequestEncoding {get;set;}
Site                                 Property   System.ComponentModel.ISite Site {get;set;}
SoapVersion                          Property   System.Web.Services.Protocols.SoapProtocolVersion SoapVersion {get;s...
Timeout                              Property   int Timeout {get;set;}
UnsafeAuthenticatedConnectionSharing Property   bool UnsafeAuthenticatedConnectionSharing {get;set;}
Url                                  Property   string Url {get;set;}
UseDefaultCredentials                Property   bool UseDefaultCredentials {get;set;}
UserAgent                            Property   string UserAgent {get;set;}
<NewDataSet>
  <Table>
    <Country>Australia</Country>
    <City>Archerfield Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Amberley Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Alice Springs Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Brisbane Airport M. O</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Coolangatta Airport Aws</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Cairns Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Charleville Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Gladstone</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Longreach Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Mount Isa Amo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Mackay Mo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Oakey Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Proserpine Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Rockhampton Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Broome Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Townsville Amo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Weipa City</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Gove Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Tennant Creek Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Yulara Aws</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Albury Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Devonport East</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Goldstream Aws</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>East Sale Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Hobart Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Launceston Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Laverton Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Moorabbin Airport Aws</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Mount Gambier Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Mildura Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Melbourne Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Macquarie Island</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Wynyard West</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Adelaide Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Albany Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Broken Hill Patton Street</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Ceduna Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Derby</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Darwin Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Bullsbrook Pearce Amo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Edinburgh M. O.</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Forrest Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Geraldton Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Kalgoorlie Boulder Amo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Kununurra Kununurra Aws</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Leigh Creek Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Learmonth Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Meekatharra Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Port Hedland Pardoo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Parafield Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Belmont Perth Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Katherine Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Woomera Aerodrome</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Bankstown Airport Aws</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Canberra</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Coffs Harbour Mo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Cooma</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Camden Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Dubbo</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Norfolk Island Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Nowra Ran Air Station</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Richmond Aus-Afb</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Sydney Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Tamworth Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Wagga Airport</City>
  </Table>
  <Table>
    <Country>Australia</Country>
    <City>Williamtown Aerodrome</City>
  </Table>
</NewDataSet>
done


PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop> type .\foobar.ps1

$url = "http://www.webservicex.net/globalweather.asmx?wsdl"


$webservicex = New-WebServiceProxy -Uri $url -namespace WebServiceProxy -Class GlobalWeatherSoap


$webservicex | gm


echo $australiancities


$australiancities.NewDataSet


$australiancities.NewDataSet.Table



 $AustralianCities = $webservicex.GetCitiesByCountry("Australia")

echo $AustralianCities

echo "done"





PS C:\Users\thufir\Desktop>
PS C:\Users\thufir\Desktop>