I am a newbie to using powershell and I have a question: why is it I can get-computerrestorepoint or get-hotfix but there is no easy command to get a listing of applications on my pc. Am I just missing something?
This blog has a bit of the details. There are two basic methods to get applications:
Basically, Win32_Product only lists MSI installed applications, so not all applications. The WMI class also has methods such as .Uninstall(), so you want to install an application you can use standard WMI WQL queries (e.g. (gwmi Win32_Product -Filter "Name='Microsoft Project Plus 2010").Uninstall()). Here are the listed methods:
Configure Method System.Management.ManagementBaseObject Configure(System.UInt16 InstallState, System.UIn... Reinstall Method System.Management.ManagementBaseObject Reinstall(System.UInt16 ReinstallMode) Uninstall Method System.Management.ManagementBaseObject Uninstall() Upgrade Method System.Management.ManagementBaseObject Upgrade(System.String PackageLocation, System.St...
However, there are cons to using Win32_Product like if you call the class it will start a consistency check and could damage applications as outlined in this blog. Then you have the registry, which will list all of the applications, but there are no built in methods, so you have to manually run the Uninstall strings to remove software (which sometimes requires parsing). Finally, there is another method, but it is only available for SCCM clients is the WMI class Win32Reg_AddRemovePrograms (also outlined in the second blog post).
There are no built-in commandlets for software, but there are a lot of canned modules and scripts that people have put together to pull software.
For a .csv file – Get-WmiObject -Class win32_product | Select-Object -Property name, version | export-csv c:\installed_programs.csv
Edit: As mentioned above it doesn't give you everything.
You must be logged in to reply to this topic.