Remote Install Software with Powershell


SUBMITTED BY: Guest

DATE: Nov. 14, 2013, 7:05 a.m.

FORMAT: Text only

SIZE: 2.3 kB

HITS: 807

  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. <#Needed for AD access. You need to have the Quest AD Powershell tools installed.#>
  11. Add-PSSnapin Quest.ActiveRoles.ADManagement
  12. <# You will get the following error if you run this script more than once in the same session:
  13. "Add-PSSnapin : Cannot add Windows PowerShell snap-in Quest.ActiveRoles.ADManagement because it is already ad
  14. ded. Verify the name of the snap-in and try again."
  15. #>
  16. #Pull Computers from AD
  17. $Computers = Get-QADComputer -searchroot 'ins-lua.com/Workstations/Deployment'
  18. <#Get Domain Admin Credential#>
  19. $Cred = Get-Credential
  20. <#Updates - List updates here. These will need to be setup in the deployments below. #>
  21. <#At this time Updates can only be deployed from a file share that accepts null sessions. aka shares that allow connections without user/pass#>
  22. $FlashAX = "\\Sever\Share\install_flash_player_10_active_x.msi"
  23. $JavaUpdate = "\\Server\Share\Oracle Java x86\jre1.6.0_24.msi"
  24. #List of Systems Skipped
  25. $Skipped = @()
  26. <# Deploy Updates To Systems.
  27. Notes:
  28. TODO: Remove Updater Startup Entries
  29. #>
  30. foreach($Computer in $Computers)
  31. {
  32. $ObjComputerName = New-Object PSObject
  33. $ObjComputerName = $computer.name
  34. $System = $ObjComputerName
  35. <# If the computer is not responding, record that we skipped it and continue. We can review this collection after the script completes. #>
  36. if(-not (Test-Connection -Quiet $System -Count 1))
  37. {
  38. $Skipped += $System
  39. }
  40. # Do Updates
  41. (Get-WMIObject -Class Win32_Product -ComputerName $System -List -Credential $Cred).Install($FlashUpdateAX,$null,$true)
  42. (Get-WMIObject -Class Win32_Product -ComputerName $System -List -Credential $Cred).Install($JavaUpdate,$null,$true)
  43. # (Get-WMIObject -Class Win32_Process -ComputerName $System -List -Credential $Cred).Create("cmd.exe /c filehere.exe /switches")
  44. }

comments powered by Disqus