

CIM must be caching and dumping in the middle of the operation. In a 30-second operation, the filtering time is negligible and well within the margin of error. Here are variations of the command with filtering to get the InstallationLocation property of the CIM object. In each case, I copied the performance data from the Output tab and placed it in comments before the command. Here's the comparative graph of the three commands in sequence. There's really not much you can do to speed this up when the base operation is so slow. You can also search the registry for the installation directory. The InstallProperties registry key for the program has an InstallLocation value that stores the installation path. Here's the InstallProperties key for my current version of PowerShell Studio in Regedit. Let's use PowerShell get the installation directory in that InstallLocation registry value. Use the Get-ChildItem cmdlet to get all of the InstallProperties registry keys. Then, look for the InstallProperties key whose DisplayName property matches the program name (or a name pattern with wildcards). Because DisplayName is a registry value, not a key, use the Get-ItemProperty cmdlet to get it. When you find a match for the program name, use Get-ItemProperty on the same registry key to get the data in the InstallLocation registry value.

The Get-ItemProperty commands look repetitive (e.g.
#Sapien powershell studio 2016 how to windows
(Get-ItemProperty -Path $entryName -Name DisplayName).DisplayName), but the Windows PowerShell registry provider returns a custom object for the DisplayName registry value, so you need to get the DisplayName property of the DisplayName custom object. (Get-ItemProperty -Path $entryName -Name InstallLocation).InstallLocation If ((Get-ItemProperty -Path $entryName -Name DisplayName).DisplayName -like $ProgramName) $entryName = $entry.Name -replace 'HKEY_LOCAL_MACHINE', 'HKLM:' $inst = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\*\Products\*\InstallProperties" Same with all registry values, including InstallLocation. Searching the registry isn't fast, but at ~5 seconds, it's much faster than the CIM/WMI query.
#Sapien powershell studio 2016 how to code
Let's make this faster! After reading Aaron Jensen's ( registry code in the awesome Carbon module, I replaced the original Get-ItemProperty calls with calls to the getValue() method of registry keys ( ), like the ones that Get-ChildItem returns in the registry. SAPIEN POWERSHELL STUDIO REVIEW WINDOWS.
