views:

192

answers:

3

I'm trying to run some funtions in the background of a PoSh script. The job never completes, but works fine when called normall. I've narrowed the problem down to the following line:

This line works fine:

$ws = New-WebServiceProxy  "http://host/Service?wsdl" -UseDefaultCredential

but this line blocks forever

start-job { New-WebServiceProxy "same url" -UseDefaultCredential } `
 | wait-job | Receive-Job

Some details: the service is local, and requires windows authentication. Client is XP & server 2003.

Why? How do get it to work?

A: 

Got this to work. What OS are you running? XP or 2003 may be a problem.

start-job { 
        $zip = New-WebServiceProxy "http://www.webservicex.net/uszip.asmx?WSDL"  -UseDefaultCredential 
} | Wait-Job | Receive-Job

$zip | get-member -type method
Doug Finke
The service requires windows authentication
Scott Weinstein
A: 

I don't have any ASMX web services to test this against, but if you look at the help of Start-Job you'll see '-Authentication- and '-Credential'. The first specifies Default, Basic, Credssp, Digest, Kerberos, Negotiate, and NegotiateWithImplicitCredential. The second could be used to provide actual credentials to run the job.

Hope that helps.

James Pogran
I get back Start-Job : The specified authentication mechanism "..." is not supported. Only "Default" is supported for this operation. And there doesn't seem to be any way to provide credential non-interactivly
Scott Weinstein
+1  A: 

You can use ConvertFrom-SecureString and ConvertTo-SecureString cmdlets

Once run

$securestring = read-host -assecurestring
convertfrom-securestring $securestring | out-file c:\securestring

it will create a secured file on disk after that you can use

$pass = Get-Content c:\securestring | convertto-securestring
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist “domain\administrator”,$pass

and

start-job { New-WebServiceProxy "same url" -Credential $cred } | wait-job | Receive-Job
Mihail Stacanov
That's helpfull, but only works as long as my password doesn't change.
Scott Weinstein