Advertisement
Guest User

Remote Install Software with Powershell

a guest
Mar 11th, 2011
2,209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.    .Synopsis
  3.     Update 3rd party software on Network computers
  4.    .Description
  5.     This script deploy's MSI & MSP Updates to computers in a list pulled from AD. Any systems that are offline at the time will be placed in $Skipped.
  6.    .Notes
  7.     NAME: Deploy3rdPartyUpdates.ps1
  8.     AUTHOR: Hugh Smalley
  9. #>
  10.  
  11. <#Needed for AD access. You need to have the Quest AD Powershell tools installed.#>
  12. Add-PSSnapin Quest.ActiveRoles.ADManagement
  13.  
  14. <# You will get the following error if you run this script more than once in the same session:
  15. "Add-PSSnapin : Cannot add Windows PowerShell snap-in Quest.ActiveRoles.ADManagement because it is already ad
  16. ded. Verify the name of the snap-in and try again."
  17. #>
  18.  
  19. #Pull Computers from AD
  20. $Computers = Get-QADComputer -searchroot 'ins-lua.com/Workstations/Deployment'
  21.  
  22. <#Get Domain Admin Credential#>
  23. $Cred = Get-Credential
  24.  
  25. <#Updates - List updates here. These will need to be setup in the deployments below. #>
  26. <#At this time Updates can only be deployed from a file share that accepts null sessions. aka shares that allow connections without user/pass#>
  27. $FlashAX = "\\Sever\Share\install_flash_player_10_active_x.msi"
  28. $JavaUpdate = "\\Server\Share\Oracle Java x86\jre1.6.0_24.msi"
  29.  
  30. #List of Systems Skipped
  31. $Skipped = @()
  32.  
  33. <# Deploy Updates To Systems.
  34.     Notes:
  35.         TODO: Remove Updater Startup Entries
  36. #>
  37.  
  38. foreach($Computer in $Computers)
  39. {  
  40.     $ObjComputerName = New-Object PSObject
  41.     $ObjComputerName = $computer.name
  42.     $System = $ObjComputerName
  43.  
  44. <# If the computer is not responding, record that we skipped it and continue. We can review this collection after the script completes. #>
  45.  
  46.     if(-not (Test-Connection -Quiet $System -Count 1))
  47.     {
  48.         $Skipped += $System
  49.     }
  50. # Do Updates
  51.     (Get-WMIObject -Class Win32_Product -ComputerName $System -List -Credential $Cred).Install($FlashUpdateAX,$null,$true)
  52.     (Get-WMIObject -Class Win32_Product -ComputerName $System -List -Credential $Cred).Install($JavaUpdate,$null,$true)
  53. #   (Get-WMIObject -Class Win32_Process -ComputerName $System -List -Credential $Cred).Create("cmd.exe /c filehere.exe /switches")
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement