【问题标题】:Get-WmiObject taking too much time to get executeGet-WmiObject 执行时间过长
【发布时间】:2018-04-25 07:08:25
【问题描述】:
Get-WmiObject -Class win32_product -ComputerName $Computer | Where-Object -FilterScript {$_.Name -match $ApplicationName}
执行大约 20 到 30 分钟需要太多时间。它之前工作过,是因为任何 Windows 更新的原因
【问题讨论】:
标签:
powershell
powershell-4.0
powershell-remoting
【解决方案2】:
Win32_Product 已损坏,可以通过直接从注册表中获取它来替换,例如:
Get-ChildItem HKLM:\SOFTWARE\$_\Microsoft\Windows\CurrentVersion\Uninstall\ | ? {($_.GetValue("DisplayName")) -like "*AappName*"}
或者如果你想在远程会话中使用Invoke-Command,那么你可以这样做:
Invoke-Command -ComputerName Computer1, Computer2 -ScriptBlock {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Publisher, InstallDate }
注意:凭据也可以在调用命令中传递,否则它将考虑 Windows 登录用户。如果您在域范围内进行操作,那么您将使用管理员凭据进行此操作。
希望对你有帮助。