1

I am trying to execute a WCF service / WSDL using Powershell, and I found I can use "New-WebServiceProxy" cmdlet to do the job.

Unfortunately it appears that if I execute directly on my environment, it will not work because it is blocked by our Proxy Server, then I found Net.WebProxy cmdlet which can glue them together.

But, I am not too familiar with the 2 cmdlet, how do I use New-WebServiceProxy but at the same time defining Proxy just like in Net.WebProxy?

Thanks

PlayKid
  • 871
  • 2
  • 10
  • 21

1 Answers1

0

See if this discussion and answers resolves your use case.

How can I set an HTTP Proxy (WebProxy) on a WCF client-side Service proxy?

As for this...

But, I am not too familiar with the 2 cmdlet, how do I use New-WebServiceProxy but at the same time defining Proxy just like in Net.WebProxy?

Are you looking for what is the difference between the two?

One is a built-in cmdlet defined to be used in a specific way and the other is not. There is no such MS provided cmdlet called, Net.WebProxy.

(Get-Command -Name *web*) -match 'proxy' | Format-Table -AutoSize

CommandType Name                Version Source                         
----------- ----                ------- ------                         
Cmdlet      New-WebServiceProxy 3.1.0.0 Microsoft.PowerShell.Management

That is a raw Windows .Net class...

See these resources:

Web​Proxy Class Definition Namespace: System.Net Assemblies:System.dll, netstandard.dll, System.Net.WebProxy.dll

Web​Proxy Constructors Definition Namespace: System.Net Assemblies:System.dll, netstandard.dll, System.Net.WebProxy.dll

... that you can leverage in PowerShell modules / scripts.

postanote
  • 15,138
  • 2
  • 14
  • 25