-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrotherPrinterFirmwareUpdate.ps1
64 lines (50 loc) · 2.93 KB
/
BrotherPrinterFirmwareUpdate.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Set your printer's IP address and model number
$PrinterIP = "192.168.1.100"
$PrinterModel = "HL-L8360CDW"
# Define the URL for the firmware download page
$FirmwareURL = "https://support.brother.com/g/b/downloadtop.aspx?c=us&lang=en&prod=$($PrinterModel.ToLower())_eus"
# Get the latest firmware version from Brother's website
$LatestFirmwareInfo = (Invoke-WebRequest -Uri $FirmwareURL -UseBasicParsing).Links |
Where-Object { $_.href -like "*.firm" } |
ForEach-Object { @{ Version = $_.innerText.Trim() -replace '[^0-9.]', ''; DownloadUrl = $_.href } } |
Sort-Object -Descending -Property Version |
Select-Object -First 1
if (!$LatestFirmwareInfo) {
Write-Host "Couldn't retrieve the latest firmware version for the printer model. Please verify the printer model and try again."
exit
}
$LatestFirmwareVersion = $LatestFirmwareInfo.Version
$LatestFirmwareDownloadUrl = $LatestFirmwareInfo.DownloadUrl
Write-Host "Latest firmware version for $($PrinterModel): $LatestFirmwareVersion"
# Connect to the remote printer and get its firmware version
$PrinterInfo = Invoke-WebRequest -Uri "http://$PrinterIP/general/information.xml" -UseBasicParsing
if (!$PrinterInfo) {
Write-Host "Couldn't connect to the remote printer. Please verify the printer's IP address and try again."
exit
}
$CurrentFirmwareVersion = ([xml]$PrinterInfo.Content).information.version
Write-Host "Current firmware version of the remote printer: $CurrentFirmwareVersion"
# Compare the current firmware version with the latest one
if ($CurrentFirmwareVersion -eq $LatestFirmwareVersion) {
Write-Host "The remote Brother printer is running the latest firmware version."
} else {
Write-Host "The remote Brother printer is NOT running the latest firmware version. An update is recommended."
$UpdateChoice = Read-Host "Do you want to download and install the latest firmware? (Y/N)"
if ($UpdateChoice -eq "Y") {
$FirmwareFile = "$env:TEMP\BrotherFirmware.firm"
Invoke-WebRequest -Uri $LatestFirmwareDownloadUrl -OutFile $FirmwareFile
if (Test-Path $FirmwareFile) {
Write-Host "Firmware file downloaded to: $FirmwareFile"
Write-Host "Uploading firmware file to the printer..."
$FirmwareUpdateUrl = "http://$PrinterIP/firmware_upload.html"
$FirmwareUpdateResult = Invoke-WebRequest -Uri $FirmwareUpdateUrl -Method Post -InFile $FirmwareFile -ContentType 'application/octet-stream'
if ($FirmwareUpdateResult.StatusCode -eq 200) {
Write-Host "Firmware update process has started. Please wait for the printer to reboot and complete the update."
} else {
Write-Host "Failed to update the firmware. Please check the printer's web interface for more details."
}
} else {
Write-Host "Failed to download the firmware file. Please try again."
}
}
}