Нет описания

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Import the necessary assemblies
  2. Add-Type -AssemblyName System.Windows.Forms
  3. Add-Type -AssemblyName System.Drawing
  4. # Create the Form
  5. $form = New-Object System.Windows.Forms.Form
  6. $form.Text = "Recently Installed Hotfixes"
  7. $form.Width = 500
  8. $form.Height = 250
  9. $form.StartPosition = "CenterScreen"
  10. # Create the Dropdown Menu
  11. $dropdown = New-Object System.Windows.Forms.ComboBox
  12. $dropdown.Location = New-Object System.Drawing.Point(50,50)
  13. $dropdown.Width = 400
  14. # Get the Recently Installed Hotfixes
  15. $hotfixes = Get-Hotfix | Select-Object -Property Description, InstalledOn | Sort-Object -Property InstalledOn -Descending
  16. # Add the Hotfixes to the Dropdown Menu
  17. foreach ($hotfix in $hotfixes) {
  18. $dropdown.Items.Add("$($hotfix.Description) - Installed On: $($hotfix.InstalledOn)")
  19. }
  20. # Create the Uninstall Button
  21. $button = New-Object System.Windows.Forms.Button
  22. $button.Text = "Uninstall Selected Hotfix"
  23. $button.Location = New-Object System.Drawing.Point(150,100)
  24. $button.Width = 200
  25. $button.Add_Click({
  26. # Get the Selected Hotfix
  27. $selectedHotfix = $dropdown.SelectedItem
  28. if ($selectedHotfix -eq $null) {
  29. [System.Windows.Forms.MessageBox]::Show("Please select a hotfix to uninstall.")
  30. } else {
  31. # Get the Description and InstalledOn properties of the Selected Hotfix
  32. $hotfixDetails = $selectedHotfix.Split(" - ")[0]
  33. $hotfixInstalledOn = $selectedHotfix.Split(" - ")[1]
  34. # Uninstall the Selected Hotfix
  35. Uninstall-WindowsFeature -Name $hotfixDetails -Remove -Restart
  36. }
  37. })
  38. # Add the Dropdown Menu and Button to the Form
  39. $form.Controls.Add($dropdown)
  40. $form.Controls.Add($button)
  41. # Show the Form
  42. $form.ShowDialog()

Powered by TurnKey Linux.