<#Description V2.0 Fleet firmware updates Acions carried out by this script: *Determines if the platform is for HP or Dell *HP Downloads the latest SUM engine from the Rackspace mirror Unzips SUM Runs SUM in silent mode against Rackspace's latest firmware repo Creates Reports and saves them in "C:\rs-pkgs\SUM_Combined_Report_*****" Will reboot device if reboot flag is true Removes SUM Addtional SUM logs can be found here C:\cpqsystem\sum\log *Dell Downloads Dell's DELL EMC System Update (DSU) from the Rackspace mirrors Installs DSU Runs DSU in silient mode against Rackspace's latest firmware repo for Dell Will reboot device if reboot flag is true DSU Logs located here "C:\dell\DELL EMC System Update\dell_dup\Log.txt" Some additional logging can be found in C:\rs-pkgs\Firmware-Update.log #> param($reboot = "False") function AvailableDriveLetter () { param([char]$ExcludedLetter) $Letter = [int][char]'C' $i = @() #getting all the used Drive letters reported by the Operating System $(Get-PSDrive -PSProvider filesystem) | ForEach-Object { $i += $_.Name } #Adding the excluded letter $i += $ExcludedLetter while ($i -contains $([char]$Letter)) { $Letter++ } return $([char]$Letter) } Remove-Item -Path "C:\rs-pkgs\Firmware-Update.log" -ErrorAction SilentlyContinue Set-Location "C:\rs-pkgs" $Loc = Get-Location $logfile = $Loc.path + "\Firmware-Update.log" $driveLetter = AvailableDriveLetter #region HP if (Get-WmiObject -Class:Win32_ComputerSystem -Filter:"Manufacturer LIKE '%HP%'" -ComputerName:localhost) { if (Test-Path "C:\rs-pkgs\sum") { try { Remove-Item -Path C:\rs-pkgs\sum -Recurse -ErrorAction SilentlyContinue $SourceLocation = "\\rax.mirror.rackspace.com\hpsum\remote_update\Current" $SourceFile = "\\rax.mirror.rackspace.com\hpsum\remote_update\sum.zip" $Username = "hpsum" $Password = ConvertTo-SecureString "readonly" -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential ($Username,$Password) New-PSDrive -Name $driveLetter -PSProvider FileSystem -Root $SourceLocation -Credential $creds -Persist -ErrorAction Stop Copy-Item $SourceFile -Destination C:\rs-pkgs\sum.zip Remove-PSDrive $driveLetter -ErrorAction SilentlyContinue Expand-Archive -LiteralPath C:\rs-pkgs\sum.zip -DestinationPath C:\rs-pkgs\ -Force } catch { $_.Exception.Message | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append exit } } else { try { $SourceLocation = "\\rax.mirror.rackspace.com\hpsum\remote_update" $SourceFile = "\\rax.mirror.rackspace.com\hpsum\remote_update\sum.zip" $Username = "hpsum" $Password = ConvertTo-SecureString "readonly" -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential ($Username,$Password) New-PSDrive -Name $driveLetter -PSProvider FileSystem -Root $SourceLocation -Credential $creds -Persist -ErrorAction Stop Copy-Item $SourceFile -Destination C:\rs-pkgs\sum.zip Remove-PSDrive $driveLetter -ErrorAction SilentlyContinue Expand-Archive -LiteralPath C:\rs-pkgs\sum.zip -DestinationPath C:\rs-pkgs\ -Force } catch { $_.Exception.Message | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append exit } } if ($reboot -eq "True") { "Update with reboot selected" | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append $cmd = [char]34 + 'C:\rs-pkgs\SUM\smartupdate.bat' + [char]34 + ' /silent /combined_report /reportdir C:\rs-pkgs /v /use_location \\rax.mirror.rackspace.com\hpsum\remote_update\Current /unc_username hpsum /unc_password readonly' $executeCMD = CMD /c $cmd | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append Start-Sleep -s 15 CMD /c "C:\rs-pkgs\SUM\clean-cache.bat /y" Remove-Item -Path C:\rs-pkgs\sum -ErrorAction SilentlyContinue -Recurse Remove-Item -Path C:\rs-pkgs\sum.zip -ErrorAction SilentlyContinue #Restart server - 30 second delay Shutdown /r /f /t 30 } else { "Update without reboot selected" | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append $cmd = [char]34 + 'C:\rs-pkgs\SUM\smartupdate.bat' + [char]34 + ' /silent /combined_report /reportdir C:\rs-pkgs /v /use_location \\rax.mirror.rackspace.com\hpsum\remote_update\Current /unc_username hpsum /unc_password readonly' $executeCMD = CMD /c $cmd | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append Start-Sleep -s 15 CMD /c "C:\rs-pkgs\SUM\clean-cache.bat /y" Remove-Item -Path C:\rs-pkgs\sum -ErrorAction SilentlyContinue -Recurse Remove-Item -Path C:\rs-pkgs\sum.zip -ErrorAction SilentlyContinue } } #endregion #region Dell if (Get-WmiObject -Class:Win32_ComputerSystem -Filter:"Manufacturer LIKE '%Dell%'" -ComputerName:localhost) { $DellApp = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq "DELL EMC System Update" } if ($DellApp) { try { $DellApp.Uninstall() Remove-Item -Path 'c:\Dell\DSU_Extract' -ErrorAction SilentlyContinue -Recurse Remove-Item -Path 'C:\dell\DELL EMC System Update' -ErrorAction SilentlyContinue -Recurse Invoke-WebRequest -Uri "http://rax.mirror.rackspace.com/media/DriversFirmware/Dell_Updates/remote_update/SYSMAN/Systems-Management_Application_DVHNP_WN64_1.7.0_A00.EXE" -OutFile "C:\rs-pkgs\Systems-Management_Application_DVHNP_WN64_1.7.0_A00.EXE" -ErrorAction Stop CMD /c "C:\rs-pkgs\Systems-Management_Application_DVHNP_WN64_1.7.0_A00.EXE /s /e=c:\Dell\DSU_Extract\" CMD /c "C:\Dell\DSU_Extract\setup.exe /S /v/qn" } catch { $_.Exception.Message | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append exit } } else { try { Invoke-WebRequest -Uri "http://rax.mirror.rackspace.com/media/DriversFirmware/Dell_Updates/remote_update/SYSMAN/Systems-Management_Application_DVHNP_WN64_1.7.0_A00.EXE" -OutFile "C:\rs-pkgs\Systems-Management_Application_DVHNP_WN64_1.7.0_A00.EXE" -ErrorAction Stop CMD /c "C:\rs-pkgs\Systems-Management_Application_DVHNP_WN64_1.7.0_A00.EXE /s /e=c:\Dell\DSU_Extract\" CMD /c "C:\Dell\DSU_Extract\setup.exe /S /v/qn" } catch { $_.Exception.Message | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append exit } } if ($reboot -eq "True") { "Update with reboot selected" | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append $cmd = [char]34 + "C:\Dell\DELL EMC System Update\DSU.exe" + [char]34 + " /n /u --source-type=REPOSITORY --source-location=http://rax.mirror.rackspace.com/media/DriversFirmware/Dell_Updates/remote_update/Current/ --log-level=4" $executeCMD = CMD /c $cmd | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append #Restart server - 30 second delay Shutdown /r /f /t 30 } else { "Update without reboot selected" | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append $cmd = [char]34 + "C:\Dell\DELL EMC System Update\DSU.exe" + [char]34 + " /n /u --source-type=REPOSITORY --source-location=http://rax.mirror.rackspace.com/media/DriversFirmware/Dell_Updates/remote_update/Current/ --log-level=4" $executeCMD = CMD /c $cmd | Out-File "C:\rs-pkgs\Firmware-Update.log" -Append } } #endregion Unregister-ScheduledTask -TaskName "Install Server_Updates" -Confirm:$false -ErrorAction SilentlyContinue