Advertisement
fellwell5

Find-MSIGUID.ps1

Mar 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <# ==============================================================================================
  2. Copyright (c) 2019 by Matthias Schaffer
  3.  
  4. NAME: Find-MSIGUID.ps1
  5.  
  6. COMMENT: Show Software GUID
  7.  
  8. HISTORY:
  9.     Rel. 1.0, 06.02.2019, fellwell5
  10.    
  11. VERSION: 1.0, fellwell5
  12.  
  13. All rights reserved.
  14. ============================================================================================== #>
  15.  
  16. # requires -version x
  17.  
  18. # change Window Title
  19. $host.ui.RawUI.WindowTitle = “Find-GUID”
  20.  
  21. Add-Type -AssemblyName System.Windows.Forms
  22. $Form = New-Object system.Windows.Forms.Form
  23. $Label2 = new-object system.windows.forms.Label
  24. $Label2.Font = 'Arial,12pt'
  25. $Label2.Text = ""
  26. $Label2.AutoSize = $True
  27. $Label2.Location = new-object system.drawing.size(5,5)
  28. $System_Drawing_Size = New-Object System.Drawing.Size
  29. $System_Drawing_Size.Width = 360
  30. $System_Drawing_Size.Height = 20
  31. $progressBar1 = New-Object System.Windows.Forms.ProgressBar
  32. $progressBar1.Name = 'progressBar1'
  33. $progressBar1.Value = 0
  34. $progressBar1.Style="Continuous"
  35. $progressBar1.Size = $System_Drawing_Size
  36. $progressBar1.Left = 5
  37. $progressBar1.Top = 35
  38. $Form.Controls.Add($Label2)
  39. $Form.Controls.Add($progressBar1)
  40. $Form.AutoScroll = $True
  41. $Form.AutoSize = $True
  42. $Form.MinimizeBox = $False
  43. $Form.MaximizeBox = $False
  44. $Form.AutoSizeMode = "GrowAndShrink"
  45. $Form.StartPosition = "CenterScreen"
  46. $Form.Topmost = $True
  47. $Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")
  48. $Form.Icon = $Icon
  49. $AnimationCount = 0
  50.  
  51.  
  52. Write-Host "#####################################"
  53. Write-Host "####          Find GUID          ####"
  54. Write-Host "####     fellwell5 06.02.2019      ####"
  55. Write-Host "#####################################"
  56. Write-Host
  57. $search = Read-Host -Prompt 'Programmname eingeben'
  58. if(-Not ($search.StartsWith("*"))){
  59.     $search = "*$search"
  60. }
  61. if(-Not ($search.EndsWith("*"))){
  62.     $search = "$search*"
  63. }
  64.  
  65. $Form.Add_Shown({$Form.Activate()})
  66. [void] $Form.Show()
  67. $Label2.Text = "Es wird nach $search gesucht."
  68. $search_job = start-job -Name Job -ScriptBlock {
  69.     Param($search)
  70.     $WMI = Get-WmiObject win32_Product | where {$_.name -like "$search"}
  71.     if($WMI.Count -eq 0){
  72.         Write-Host "Kein Programm für $search gefunden." -BackgroundColor Red
  73.     }else{
  74.         $WMI
  75.     }
  76. } -ArgumentList $search
  77.  
  78. while ($search_job.JobStateInfo.State -eq "Running"){
  79.     if ($AnimationCount -gt 99){$AnimationCount = 0}
  80.     $AnimationCount++
  81.     $progressBar1.Value = $AnimationCount
  82.     $Form.Refresh()
  83.     Start-Sleep -Milliseconds 100
  84. }
  85. $progressBar1.Value = 100
  86. $Form.Close()
  87. $search_job | Receive-Job -AutoRemoveJob -Wait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement