From 7a54394d829cd84f71b99ccb2baa34df00e3cba0 Mon Sep 17 00:00:00 2001 From: jayrodksmith <51105538+jayrodksmith@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:34:27 +0800 Subject: [PATCH 1/7] Add Dell start date --- Public/Get-WarrantyDell.ps1 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Public/Get-WarrantyDell.ps1 b/Public/Get-WarrantyDell.ps1 index c6b661b..ffe39ac 100644 --- a/Public/Get-WarrantyDell.ps1 +++ b/Public/Get-WarrantyDell.ps1 @@ -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]@{ @@ -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 @@ -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 From 45d64f5e8f3aa2d0038e43daa2f09b9a15893a8f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 11 Mar 2024 15:34:43 +0000 Subject: [PATCH 2/7] Combine PowerShell Functions into 1 script for RMM --- EasyWarrantyCheck_RMM.ps1 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/EasyWarrantyCheck_RMM.ps1 b/EasyWarrantyCheck_RMM.ps1 index f8f494e..c0361fa 100644 --- a/EasyWarrantyCheck_RMM.ps1 +++ b/EasyWarrantyCheck_RMM.ps1 @@ -409,7 +409,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]@{ @@ -458,8 +458,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 @@ -468,7 +485,7 @@ function Get-WarrantyDell { $WarObj = [PSCustomObject]@{ 'Serial' = $serial 'Warranty Product name' = $null - 'StartDate' = $null + 'StartDate' = $warStartDate 'EndDate' = $warEndDate 'Warranty Status' = $warrantystatus 'Client' = $null From fffe6f5eeff4cd44b1a0cc446d105f7d559a4341 Mon Sep 17 00:00:00 2001 From: jayrodksmith <51105538+jayrodksmith@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:37:22 +0800 Subject: [PATCH 3/7] Add headless mode back in --- Public/Get-WarrantyDell.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/Get-WarrantyDell.ps1 b/Public/Get-WarrantyDell.ps1 index ffe39ac..8a67883 100644 --- a/Public/Get-WarrantyDell.ps1 +++ b/Public/Get-WarrantyDell.ps1 @@ -52,7 +52,7 @@ function Get-WarrantyDell { } # Start a new browser session with headless mode try{ - $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $false + $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true }catch{ Write-Verbose $_.Exception.Message $WarObj = [PSCustomObject]@{ From 90bbb7263245abd40628fe95c4bff4c646e45be4 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 11 Mar 2024 15:37:34 +0000 Subject: [PATCH 4/7] Combine PowerShell Functions into 1 script for RMM --- EasyWarrantyCheck_RMM.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyWarrantyCheck_RMM.ps1 b/EasyWarrantyCheck_RMM.ps1 index c0361fa..0cd9aca 100644 --- a/EasyWarrantyCheck_RMM.ps1 +++ b/EasyWarrantyCheck_RMM.ps1 @@ -409,7 +409,7 @@ function Get-WarrantyDell { } # Start a new browser session with headless mode try{ - $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $false + $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true }catch{ Write-Verbose $_.Exception.Message $WarObj = [PSCustomObject]@{ From 0614e4cdc575bf7d081e4ca220120dcd4ba3bab1 Mon Sep 17 00:00:00 2001 From: jayrodksmith <51105538+jayrodksmith@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:53:26 +0800 Subject: [PATCH 5/7] HP function Fix --- Public/Get-WarrantyHP.ps1 | 50 ++++++++++----------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/Public/Get-WarrantyHP.ps1 b/Public/Get-WarrantyHP.ps1 index 368e171..fd4237a 100644 --- a/Public/Get-WarrantyHP.ps1 +++ b/Public/Get-WarrantyHP.ps1 @@ -149,19 +149,13 @@ function Get-WarrantyHP { } # Find the element containing the 'Start date' text try { - $startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c70-0']") + $startDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Start date')]/following-sibling::div[contains(@class,'text')]") } catch { $startDateElement = $null + Write-Host "Could not find warranty Start date" } - if (-not $startDateElement) { - try { - $startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c72-0']") - } - catch { - Write-Host "Could not find warranty Start date" - } - } + if ($startDateElement) { # Get the text of the 'Start date' element $startDateText = $startDateElement.Text @@ -169,19 +163,14 @@ function Get-WarrantyHP { } try { # Find the element containing the 'End date' text - $endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c70-0']") + $endDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'End date')]/following-sibling::div[contains(@class,'text')]") + } catch { $endDateElement = $null + Write-Host "Could not find warranty End date" } - if (-not $endDateElement) { - try { - $endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c72-0']") - } - catch { - Write-Host "Could not find warranty End date" - } - } + if ($endDateElement) { # Get the text of the 'End date' element $endDateText = $endDateElement.Text @@ -189,19 +178,13 @@ function Get-WarrantyHP { } try { # Find the element containing the 'Warranty Status' or 'Time Remaining' text - $warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c70-0']") + $warrantyStatusElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Time Remaining')]/following-sibling::div[contains(@class,'text')]") } catch { $warrantyStatusElement = $null + Write-Host "Could not find warranty Status" } - if (-not $warrantyStatusElement) { - try { - $warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c72-0']") - } - catch { - Write-Host "Could not find warranty Status" - } - } + if ($warrantyStatusElement) { $warrantyStatusText = $warrantyStatusElement.Text if ($warrantyStatusText -match "Expired") { @@ -210,20 +193,13 @@ function Get-WarrantyHP { } try { # Find the element containing the 'Product' information - $h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c70-0 > h2") + $h2Element = $driver.FindElementByXPath("//main//h2") } catch { $h2Element = $null + Write-Host "Could not find Product Name" } - if (-not $h2Element) { - try { - # Find the element containing the 'Product' information - $h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c72-0 > h2") - } - catch { - $h2Element = $null - } - } + if ($h2Element) { $product = $h2Element.Text } From 42cd4ae27c5fb18d836ed6889f00535a0438f783 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 12 Mar 2024 04:53:42 +0000 Subject: [PATCH 6/7] Combine PowerShell Functions into 1 script for RMM --- EasyWarrantyCheck_RMM.ps1 | 50 ++++++++++----------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/EasyWarrantyCheck_RMM.ps1 b/EasyWarrantyCheck_RMM.ps1 index 0cd9aca..4035cc0 100644 --- a/EasyWarrantyCheck_RMM.ps1 +++ b/EasyWarrantyCheck_RMM.ps1 @@ -808,19 +808,13 @@ function Get-WarrantyHP { } # Find the element containing the 'Start date' text try { - $startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c70-0']") + $startDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Start date')]/following-sibling::div[contains(@class,'text')]") } catch { $startDateElement = $null + Write-Host "Could not find warranty Start date" } - if (-not $startDateElement) { - try { - $startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c72-0']") - } - catch { - Write-Host "Could not find warranty Start date" - } - } + if ($startDateElement) { # Get the text of the 'Start date' element $startDateText = $startDateElement.Text @@ -828,19 +822,14 @@ function Get-WarrantyHP { } try { # Find the element containing the 'End date' text - $endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c70-0']") + $endDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'End date')]/following-sibling::div[contains(@class,'text')]") + } catch { $endDateElement = $null + Write-Host "Could not find warranty End date" } - if (-not $endDateElement) { - try { - $endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c72-0']") - } - catch { - Write-Host "Could not find warranty End date" - } - } + if ($endDateElement) { # Get the text of the 'End date' element $endDateText = $endDateElement.Text @@ -848,19 +837,13 @@ function Get-WarrantyHP { } try { # Find the element containing the 'Warranty Status' or 'Time Remaining' text - $warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c70-0']") + $warrantyStatusElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Time Remaining')]/following-sibling::div[contains(@class,'text')]") } catch { $warrantyStatusElement = $null + Write-Host "Could not find warranty Status" } - if (-not $warrantyStatusElement) { - try { - $warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c72-0']") - } - catch { - Write-Host "Could not find warranty Status" - } - } + if ($warrantyStatusElement) { $warrantyStatusText = $warrantyStatusElement.Text if ($warrantyStatusText -match "Expired") { @@ -869,20 +852,13 @@ function Get-WarrantyHP { } try { # Find the element containing the 'Product' information - $h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c70-0 > h2") + $h2Element = $driver.FindElementByXPath("//main//h2") } catch { $h2Element = $null + Write-Host "Could not find Product Name" } - if (-not $h2Element) { - try { - # Find the element containing the 'Product' information - $h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c72-0 > h2") - } - catch { - $h2Element = $null - } - } + if ($h2Element) { $product = $h2Element.Text } From 5208d902088792ef497f86f26a21ceef398778e0 Mon Sep 17 00:00:00 2001 From: jayrodksmith <51105538+jayrodksmith@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:54:35 +0800 Subject: [PATCH 7/7] 1.0.2 Release --- CHANGELOG.md | 14 ++++++++++++++ EasyWarrantyCheck.psd1 | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1668d63..9d89946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ ## [Unreleased] +# [1.0.2] - 11-03-2024 + +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +- HP Lookup function + # [1.0.1] - 11-03-2024 ### Added diff --git a/EasyWarrantyCheck.psd1 b/EasyWarrantyCheck.psd1 index bc401af..d3282af 100644 --- a/EasyWarrantyCheck.psd1 +++ b/EasyWarrantyCheck.psd1 @@ -12,7 +12,7 @@ RootModule = 'EasyWarrantyCheck.psm1' # Version number of this module. - ModuleVersion = '1.0.1' + ModuleVersion = '1.0.2' # Supported PSEditions # CompatiblePSEditions = @()