# Import the necessary assemblies Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # Create the Form $form = New-Object System.Windows.Forms.Form $form.Text = "Recently Installed Hotfixes" $form.Width = 500 $form.Height = 250 $form.StartPosition = "CenterScreen" # Create the Dropdown Menu $dropdown = New-Object System.Windows.Forms.ComboBox $dropdown.Location = New-Object System.Drawing.Point(50,50) $dropdown.Width = 400 # Get the Recently Installed Hotfixes $hotfixes = Get-Hotfix | Select-Object -Property Description, InstalledOn | Sort-Object -Property InstalledOn -Descending # Add the Hotfixes to the Dropdown Menu foreach ($hotfix in $hotfixes) { $dropdown.Items.Add("$($hotfix.Description) - Installed On: $($hotfix.InstalledOn)") } # Create the Uninstall Button $button = New-Object System.Windows.Forms.Button $button.Text = "Uninstall Selected Hotfix" $button.Location = New-Object System.Drawing.Point(150,100) $button.Width = 200 $button.Add_Click({ # Get the Selected Hotfix $selectedHotfix = $dropdown.SelectedItem if ($selectedHotfix -eq $null) { [System.Windows.Forms.MessageBox]::Show("Please select a hotfix to uninstall.") } else { # Get the Description and InstalledOn properties of the Selected Hotfix $hotfixDetails = $selectedHotfix.Split(" - ")[0] $hotfixInstalledOn = $selectedHotfix.Split(" - ")[1] # Uninstall the Selected Hotfix Uninstall-WindowsFeature -Name $hotfixDetails -Remove -Restart } }) # Add the Dropdown Menu and Button to the Form $form.Controls.Add($dropdown) $form.Controls.Add($button) # Show the Form $form.ShowDialog()