在 Windows XP 上 - 如何使用需要 Windows 身份验证的 PowerShell 后台作业

发布于 2024-08-29 17:56:28 字数 406 浏览 2 评论 0原文

我正在尝试在 PoSh 脚本的后台运行一些函数。这项工作永远不会完成,但在正常情况下工作正常。我已将问题缩小到以下行:

此行工作正常:

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

但此行永远阻塞

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

一些细节:该服务是本地的,并且需要 Windows 身份验证。客户端是XP &服务器2003。

为什么?我怎样才能让它发挥作用?

I'm trying to run some functions in the background of a PoSh script. The job never completes, but works fine when called normal. 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 I get it to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心清如水 2024-09-05 17:56:28

您可以使用 ConvertFrom-SecureString 和 ConvertTo-SecureString cmdlet

一旦运行,

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

它将在磁盘上创建一个安全文件
之后你可以使用

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

start-job { New-WebServiceProxy "same url" -Credential $cred } | wait-job | Receive-Job

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
山人契 2024-09-05 17:56:28

得到这个工作。您运行什么操作系统? XP或2003可能有问题。

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

$zip | get-member -type method

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
尐偏执 2024-09-05 17:56:28

我没有任何 ASMX Web 服务来对此进行测试,但如果您查看 Start-Job 的帮助,您将看到“-Authentication-”和“-Credential”。第一个指定 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。第二个可用于提供运行作业的实际凭据。

希望有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文