Skip to content

Commit

Permalink
Combine PowerShell Functions into 1 script for RMM
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Mar 21, 2024
1 parent 854f6c4 commit 379f899
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions EasyWarrantyCheck_RMM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -752,32 +752,28 @@ function Get-WarrantyHP {
}
}
function Set-Privacy {
# Try Click Iframe if exist
try{
$privacyButton = $driver.FindElementById("onetrust-accept-btn-handler")
do {
try { $privacyButton = $driver.FindElementById("onetrust-accept-btn-handler") } catch {}
if ($privacyButton.Text -eq "I ACCEPT") {
$privacyButton.Click()
} catch {

}
Start-Sleep -Seconds 1
}
} until ($privacyButton.Text -ne "I ACCEPT")
}
# Navigate to the warranty check URL
Write-Host "Checking HP website for serial : $Serial"
$driver.Navigate().GoToUrl("https://support.hp.com/au-en/check-warranty")
# Locate and input the serial number into the form
Write-Verbose "Waiting for any popups"
Start-Sleep -Seconds 15
Write-Verbose "Tyring to get rid of popups"
Start-Sleep -Seconds 3
Set-Privacy
Set-Iframe
Write-Verbose "Inputting serial info"
# Locate and input the serial number into the form
$serialnumber = $Serial
$inputField = $driver.FindElementById("inputtextpfinder")
$inputField.SendKeys($serialnumber)
$submitButton = $driver.FindElementById("FindMyProduct")
$submitButton.Click()
# Wait for the page to load (you might need to adjust the sleep time)
Write-Host "Waiting for results......."
Start-Sleep -Seconds 15
Start-Sleep -Seconds 12
# Check if the error message exists
try {
$errorMsgElement = $driver.FindElementByClassName("errorTxt")
Expand All @@ -795,7 +791,7 @@ function Get-WarrantyHP {
$submitButton = $driver.FindElementById("FindMyProductNumber")
$submitButton.Click()
Write-Host "Waiting for results......."
Start-Sleep -Seconds 15
Start-Sleep -Seconds 12
}
elseif ($null -ne $errorMsgElement -and $null -ne $SystemSKU -and $global:ServerMode -eq $true) {
Write-Host "SystemSKU not provided"
Expand All @@ -815,7 +811,7 @@ function Get-WarrantyHP {
$submitButton = $driver.FindElementById("FindMyProductNumber")
$submitButton.Click()
Write-Host "Waiting for results......."
Start-Sleep -Seconds 15
Start-Sleep -Seconds 12
}
catch {
Write-Host "SystemSKU key does not exist in the specified registry path."
Expand Down

0 comments on commit 379f899

Please sign in to comment.