WMI Slideshow

  1. ################################################################## 
  2. ####                                                          #### 
  3. ####                 REMOTE INSTALL                           ####        
  4. ####                                                          #### 
  5. ####             Writen by Felipe Binotto                     #### 
  6. ####               Date: 01/05/10                             #### 
  7. ####                                                          ####  
  8. ####                                                          #### 
  9. ################################################################## 
  10.  
  11.  
  12.  
  13. function remoteinstall { 
  14.  
  15. $returnvalue = (Get-WmiObject -ComputerName $address.Text -List | Where-Object -FilterScript {$_.Name -eq "win32_product"}).install($location.Text) | Select-Object -Property returnvalue 
  16. if($returnvalue.returnvalue -eq "0"
  17. {[Windows.Forms.MessageBox]::Show("Installation was successful!")} 
  18. else{[Windows.Forms.MessageBox]::Show("Installation was not successful!")} 
  19.  
  20. [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms"
  21. [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing"
  22.  
  23. $Form = New-Object System.Windows.Forms.Form 
  24.  
  25. $Form.width = 500 
  26. $Form.height = 350 
  27. $Form.Text = "Remote Uninstall" 
  28. $Form.backcolor = "#5D8AA8" 
  29. $Form.maximumsize = New-Object System.Drawing.Size(500, 350) 
  30. $Form.startposition = "centerscreen" 
  31. $Form.KeyPreview = $True 
  32. $Form.Add_KeyDown({if ($_.KeyCode -eq "Enter")  
  33.     {remoteinstall}}) 
  34. $Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")  
  35.     {$Form.Close()}}) 
  36.  
  37. $Button = new-object System.Windows.Forms.Button 
  38. $Button.Location = new-object System.Drawing.Size(180,200) 
  39. $Button.Size = new-object System.Drawing.Size(130,30) 
  40. $Button.Text = "Install!" 
  41. $Button.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(255, 255, 192); 
  42. $Button.Image = [System.Drawing.Image]::FromFile("c:\mytools\gifs\lupa.ico"
  43. $Button.ImageAlign = [System.Drawing.ContentAlignment]::MiddleLeft
  44. $button.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat 
  45. $Button.Add_Click({remoteinstall}) 
  46.  
  47. $Form.Controls.Add($Button
  48.  
  49. $address = new-object System.Windows.Forms.TextBox 
  50. $address.Location = new-object System.Drawing.Size(65,60) 
  51. $address.Size = new-object System.Drawing.Size(100,20) 
  52.  
  53. $Form.Controls.Add($address
  54.  
  55. $addresslabel = new-object System.Windows.Forms.Label 
  56. $addresslabel.Location = new-object System.Drawing.Size(70,10) 
  57. $addresslabel.size = new-object System.Drawing.Size(100,50) 
  58. $addresslabel.Font = new-object System.Drawing.Font("Microsoft Sans Serif",12,[System.Drawing.FontStyle]::Bold
  59. $addresslabel.Text = "Computer" 
  60. $Form.Controls.Add($addresslabel
  61.  
  62. $locationlabel = new-object System.Windows.Forms.Label 
  63. $locationlabel.Location = new-object System.Drawing.Size(260,10) 
  64. $locationlabel.size = new-object System.Drawing.Size(200,50) 
  65. $locationlabel.Font = new-object System.Drawing.Font("Microsoft Sans Serif",12,[System.Drawing.FontStyle]::Bold
  66. $locationlabel.Text = "MSI Location" 
  67. $Form.Controls.Add($locationlabel
  68.  
  69. $location = new-object System.Windows.Forms.TextBox 
  70. $location.Location = new-object System.Drawing.Size(200,60) 
  71. $location.Size = new-object System.Drawing.Size(250,20) 
  72.  
  73. $Form.Controls.Add($location
  74.  
  75. $warning = new-object System.Windows.Forms.Label 
  76. $warning.Location = new-object System.Drawing.Size(200,90) 
  77. $warning.size = new-object System.Drawing.Size(200,50) 
  78. $warning.Font = new-object System.Drawing.Font("Microsoft Sans Serif",7) 
  79. $warning.Text = "Use UNC path `nFile must be in the target PC" 
  80. $Form.Controls.Add($warning
  81.  
  82.  
  83. $Form.Add_Shown({$Form.Activate()}) 
  84. $Form.ShowDialog() 
 
Loading...
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.