Reputation: 399
Get-WmiObject -Class win32_product -ComputerName $Computer | Where-Object -FilterScript {$_.Name -match $ApplicationName}
It is taking too much time to execute approximately 20 to 30 minutes. it was working earlier, is it cause because of any windows update
Upvotes: 1
Views: 1860
Reputation: 9133
Win32_Product is broken and can be replaced by fetching it from registry directly like:
Get-ChildItem HKLM:\SOFTWARE\$_\Microsoft\Windows\CurrentVersion\Uninstall\ | ? {($_.GetValue("DisplayName")) -like "*AappName*"}
OR if you want to have it in remote session using Invoke-Command
, then you can do like this:
Invoke-Command -ComputerName Computer1, Computer2 -ScriptBlock {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Publisher, InstallDate }
Note: The credentials also can be passed in the invoke-command else it will consider the windows login user. If you are doing domain wide, then you use Admin creds for this operation.
Hope it helps.
Upvotes: 0
Reputation: 8442
Win32_Product
is known to be very slow because it isn't just enumerating the installed applications, but it also checks/repairs the MSI installs:
Event log message indicates that the Windows Installer reconfigured all installed applications
Upvotes: 4