Montag, 1. Juni 2015

automated uninstall of old programs with powershell

powershell:

show old programs: (installdate before 2010PS >
Get-WmiObject -Class Win32_Product -ComputerName . | Where-Object -FilterScript {$_.InstallDate -lt "20100000"} |  Where-Object -FilterScript {$_.Name -NotLike "windows*"} | Where-Object -FilterScript {$_.Name -NotLike "Microsoft*"} | Where-Object -FilterScript {$_.Name -NotLike "AMD*"} | Where-Object -FilterScript {$_.Name -NotLike "google*"} Where-Object -FilterScript {$_.Name -NotLike "7-zip*"} |Where-Object -FilterScript {$_.Name -NotLike ""} | Format-List -Property Name,InstallDate

remove old programs:
PS >
( Get-WmiObject -Class Win32_Product -ComputerName . | Where-Object -FilterScript {$_.InstallDate -lt "20100000"} |  Where-Object -FilterScript {$_.Name -NotLike "windows*"} | Where-Object -FilterScript {$_.Name -NotLike "Microsoft*"} | Where-Object -FilterScript {$_.Name -NotLike "AMD*"} | Where-Object -FilterScript {$_.Name -NotLike ""} ).Uninstall()

remove all microsoft visualstudio programs:Get-WmiObject -Class Win32_Product -ComputerName . | Where-Object -FilterScript {$_.Name -Like "Microsoft Visual*"} ).Uninstall()

References:
Working with Software Installations
https://technet.microsoft.com/en-us/library/dd347651.aspx?f=255&MSPPError=-2147217396

Removing Objects from the Pipeline (Where-Object)
https://technet.microsoft.com/de-de/library/dd347549.aspx
Kommentar veröffentlichen