Skip to content

Commit

Permalink
Add Dell start date
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrodksmith authored Mar 11, 2024
1 parent b8e2015 commit 7a54394
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Public/Get-WarrantyDell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Get-WarrantyDell {
}
# Start a new browser session with headless mode
try{
$driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true
$driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $false
}catch{
Write-Verbose $_.Exception.Message
$WarObj = [PSCustomObject]@{
Expand Down Expand Up @@ -101,8 +101,25 @@ function Get-WarrantyDell {
$warEndDate = $FormattedDate
$warrantystatus = "In Warranty"
}
# Try for Start Date
try {
$checkDeviceDetails = $driver.FindElementByClassName("dds__button--secondary")
$checkDeviceDetails.Click()
Start-Sleep -Seconds 10
$ManageServicesButton = $driver.FindElementByClassName("viewDetailsWarranty")
$ManageServicesButton.Click()
Start-Sleep -Seconds 10
$PurchaseDateElement = $driver.FindElementById("dsk-purchaseDt")
$PurchaseDate = $PurchaseDateElement.Text
$WarrantystartDate = [datetime]::ParseExact($PurchaseDate, "dd MMM yyyy", [System.Globalization.CultureInfo]::InvariantCulture)
$warStartDate = $WarrantystartDate.ToString($dateformat)
} catch {
Write-Host "The purchase date field could not be found."
$warStartDate = $null
}

} else {
Write-Host "No matching text found for warranty status"
Write-Host "No matching text found for warranty end date "
}
# Close the browser
Stop-SeleniumModule -WebDriver $Seleniumdrivermode
Expand All @@ -111,7 +128,7 @@ function Get-WarrantyDell {
$WarObj = [PSCustomObject]@{
'Serial' = $serial
'Warranty Product name' = $null
'StartDate' = $null
'StartDate' = $warStartDate
'EndDate' = $warEndDate
'Warranty Status' = $warrantystatus
'Client' = $null
Expand Down

0 comments on commit 7a54394

Please sign in to comment.