Q:

Using PowerShell's New-WebServiceProxy to access a net.tcp endpoint

I am trying to access a net.tcp endpoint from powershell.
I would like to use New-WebServiceProxy for that purpose, however I am not sure if it can be done.
Right now I get a 
    
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewWebServiceProxy 

when pointing it at the wsdl (which I have heavly hand written, so it could be that...)

A:

You simply cannot do this. New-WebServiceProxy is not a WCF proxy, its a http soap proxy.
You could probably use a combination of svcutil.exe and Add-Type to generate the proxy on the fly on machines that have svcutil.exe installed.
A more complex example in C# that you might be able to translate to powershell is available here.

A:

Apparently you have been able to do this since December 22nd 2008. Christian Glessner wrote a WCF Proxy generator.
The original blog post in which he described it is here. He also posted the script in this PoshCode.org post.
I updated the code to Powershell v2. I'd suggest using that version. I talk about my version on this blog post.
If you use that code, dotsource it from another script, don't include it inline. Here is an example using my version of the code:
# My example WCF service:
# https://github.com/justaprogrammer/EchoService
. .\wcf.ps1

$wsdlImporter = Get-WsdlImporter 'http://localhost.fiddler:14232/EchoService.svc/mex'
Get-WsdlImporter 'http://localhost.fiddler:14232/EchoService.svc' -HttpGet
Get-WsdlImporter 'http://localhost.fiddler:14232/EchoService.svc?wsdl' -HttpGet 

$proxyType = Get-WcfProxyType $wsdlImporter

$endpoints = $wsdlImporter.ImportAllEndpoints();
$proxy = New-Object $proxyType($endpoints[0].Binding, $endpoints[0].Address);
$proxy = Get-WcfProxy 'http://localhost.fiddler:14232/EchoService.svc/mex'
$proxy.Echo("Justin Dearing");

Get-Help Get-WsdlImporter
Get-Help Get-WcfProxyType
Get-Help Get-WcfProxy

