在 Start-Job 脚本块内时,带有凭据的 Get-WmiObject 失败
我使用 Get-WmiObjet cmdlet 成功从 Windows 2000 计算机检索一些信息。这些计算机不是我们域的一部分,因此我使用 -Credential 参数来传递本地管理员凭据。
我现在尝试使用 Start-Job 并行运行多个 WMI 查询,但我什至无法让一个查询工作。
当我运行以下命令时:
Start-Job -initializationscript {$cred = get-credential -credential administrator} -scriptblock {gwmi win32_computersystem -ComputerName 10.1.2.3 -Credential $cred}
创建了一个作业,系统会提示我输入凭据,但该作业永远不会完成,其状态始终为“正在运行”。
当然:
C:\>$cred = Get-Credential -credential administrator
C:\>gwmi win32_computersystem -ComputerName 10.1.2.3 -Credential $cred
效果很好。
如何使用备用凭据让 Get-WmiObject 在 Start-Job 中成功运行?
感谢您的帮助。
I am successfully retrieving some information from Windows 2000 machines using the Get-WmiObjet cmdlet. These machines are not part of our domain so I am using the -Credential parameter to pass local administrator credentials.
I am now trying to run several WMI queries in parallel using Start-Job but I can't get even one query to work.
When I run the following:
Start-Job -initializationscript {$cred = get-credential -credential administrator} -scriptblock {gwmi win32_computersystem -ComputerName 10.1.2.3 -Credential $cred}
a job is created, I am prompted for the credentials, but the job never completes, its state is always "Running".
Of course:
C:\>$cred = Get-Credential -credential administrator
C:\>gwmi win32_computersystem -ComputerName 10.1.2.3 -Credential $cred
works just fine.
How do I get Get-WmiObject to run successfully within Start-Job with alternate credentials?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
看起来后台作业被阻止输入,并且因此一直运行。
Try this:
Looks like the background job is blocked for input and has been running forever for that reason.