【问题标题】: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


    【解决方案1】:

    Win32_Product 速度非常慢,因为它不仅枚举已安装的应用程序,而且还检查/修复 MSI 安装:

    Event log message indicates that the Windows Installer reconfigured all installed applications

    【讨论】:

      【解决方案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 登录用户。如果您在域范围内进行操作,那么您将使用管理员凭据进行此操作。

      希望对你有帮助。

      【讨论】:

        猜你喜欢
        • 2021-02-11
        • 2018-01-19
        • 2023-03-16
        • 1970-01-01
        • 1970-01-01
        • 2020-11-14
        • 1970-01-01
        • 1970-01-01
        • 2021-10-10
        相关资源
        最近更新 更多