diff --git a/CHANGELOG.md b/CHANGELOG.md index c95a264..1668d63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ ## [Unreleased] +# [1.0.1] - 11-03-2024 + +### Added + +- Minor Verbose logging + +### Changed + +- Modules now check for specific version + +### Deprecated + +### Removed + +### Fixed + +- Chrome Bug + # [1.0.0] - 10-03-2024 ### Added diff --git a/EasyWarrantyCheck.psd1 b/EasyWarrantyCheck.psd1 index 06f7d81..bc401af 100644 --- a/EasyWarrantyCheck.psd1 +++ b/EasyWarrantyCheck.psd1 @@ -12,7 +12,7 @@ RootModule = 'EasyWarrantyCheck.psm1' # Version number of this module. - ModuleVersion = '1.0.0' + ModuleVersion = '1.0.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/EasyWarrantyCheck_RMM.ps1 b/EasyWarrantyCheck_RMM.ps1 index 9c72d57..f8f494e 100644 --- a/EasyWarrantyCheck_RMM.ps1 +++ b/EasyWarrantyCheck_RMM.ps1 @@ -26,6 +26,7 @@ function Get-Warranty { # Web Driver mode, Edge or Chrome ( Edge Beta Support ) [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [Parameter(Mandatory = $false, ParameterSetName = 'CentralNinja')] [ValidateSet('Chrome', 'Edge')] [String]$Seleniumdrivermode = 'Chrome', @@ -36,7 +37,7 @@ function Get-Warranty { # Enable Registry Storing [Parameter(Mandatory = $false, ParameterSetName = 'Default')] [bool]$EnableRegistry = $true, - + # Registry Path [Parameter(Mandatory = $false, ParameterSetName = 'Default')] [String]$RegistryPath = 'HKLM:\SOFTWARE\RMMCustomInfo\', @@ -46,6 +47,7 @@ function Get-Warranty { [bool]$ForceUpdate = $false, # Custom Machine Details, available in both sets + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] [Parameter(Mandatory = $false, ParameterSetName = 'CentralNinja')] [String]$Serial = 'Automatic', @@ -252,13 +254,14 @@ function Get-WarrantyAsus { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Start a new browser session with headless mode try{ $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true }catch{ + Write-Verbose $_.Exception.Message $WarObj = [PSCustomObject]@{ 'Serial' = $Serial 'Warranty Product name' = $null @@ -269,7 +272,7 @@ function Get-WarrantyAsus { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Navigate to the warranty check URL @@ -284,7 +287,7 @@ function Get-WarrantyAsus { $submitcheckcookiesButton = $driver.FindElementByXPath("//div[@class='btn-asus btn-ok btn-read-ck' and @aria-label='Accept']") $submitcheckcookiesButton.Click() } catch{ - + Write-Verbose $_.Exception.Message } $checkPrivacyButton = $driver.FindElementById("checkPrivacy") $checkPrivacyButton.Click() @@ -401,13 +404,14 @@ function Get-WarrantyDell { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Start a new browser session with headless mode try{ $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true }catch{ + Write-Verbose $_.Exception.Message $WarObj = [PSCustomObject]@{ 'Serial' = $Serial 'Warranty Product name' = $null @@ -418,7 +422,7 @@ function Get-WarrantyDell { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Navigate to the warranty check URL @@ -526,7 +530,7 @@ function Get-WarrantyEdsys { try { $response = Invoke-WebRequest -Uri $url -Method Post -Body $payload -ContentType "application/x-www-form-urlencoded" -UseBasicParsing }catch{ - Write-Host $($_.Exception.Message) + Write-Verbose $_.Exception.Message } if($response){ # Output the response @@ -677,6 +681,7 @@ function Get-WarrantyHP { } catch { if ($PSCmdlet.ParameterSetName -eq 'Default') { + Write-Verbose $_.Exception.Message Write-Host "###########################" Write-Host "WARNING" Write-Host "$($browserinstalled.software) not detected" @@ -700,7 +705,7 @@ function Get-WarrantyHP { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } catch { @@ -715,7 +720,7 @@ function Get-WarrantyHP { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } } @@ -741,13 +746,13 @@ function Get-WarrantyHP { $errorMsgElement = $driver.FindElementByClassName("errorTxt") } catch { - Write-Debug "No Product Model required" + Write-Verbose "No Product Model required" } if ($null -ne $errorMsgElement -and $null -ne $SystemSKU) { # Error message found Write-Host "Using SystemSKU input" - Write-Debug "Need Product ID" + Write-Verbose "Need Product ID" $productField = $driver.FindElementById("product-number inputtextPN") $productField.SendKeys($SystemSKU) $submitButton = $driver.FindElementById("FindMyProductNumber") @@ -761,7 +766,7 @@ function Get-WarrantyHP { elseif ($null -ne $errorMsgElement -and $global:ServerMode -ne $true) { # Error message found Write-Host "Searching for additional SystemSKU......." - Write-Debug "Need Product ID" + Write-Verbose "Need Product ID" # Define the registry path $regPath = "HKLM:\HARDWARE\DESCRIPTION\System\BIOS" # Get the value of "SystemSKU" if it exists @@ -1237,18 +1242,19 @@ function Get-RunAsUserModule { #> try { - Set-ExecutionPolicy Bypass -scope Process -Force -ErrorAction SilentlyContinue | Out-Null - }catch{ + Set-ExecutionPolicy Bypass -Scope Process -Force -ErrorAction SilentlyContinue | Out-Null + } catch { } - Import-Module PowerShellGet - $RunAsUser = Get-Module -Name RunAsUser -ListAvailable + Import-Module PowerShellGet -Verbose:$false + $RunAsUser = Get-Module -Name RunAsUser -ListAvailable | Where-Object { $_.Version -eq '2.4.0' } if (-not $RunAsUser) { - Get-PackageProvider -Name "nuGet" -ForceBootstrap | Out-Null - Install-Module RunAsUser -Force + Get-PackageProvider -Name "nuGet" -ForceBootstrap -Verbose:$false | Out-Null + Install-Module RunAsUser -Force -RequiredVersion '2.4.0' -Verbose:$false } - Import-Module RunAsUser -Force -} + Import-Module RunAsUser -Force -Version '2.4.0' -Verbose:$false +} + function Get-SeleniumModule { <# @@ -1267,13 +1273,13 @@ function Get-SeleniumModule { }catch{ } - Import-Module PowerShellGet - $seleniumModule = Get-Module -Name Selenium -ListAvailable + Import-Module PowerShellGet -Verbose:$false + $seleniumModule = Get-Module -Name Selenium -ListAvailable | Where-Object { $_.Version -eq '3.0.1' } if (-not $seleniumModule) { - Get-PackageProvider -Name "nuGet" -ForceBootstrap | Out-Null - Install-Module Selenium -Force + Get-PackageProvider -Name "nuGet" -ForceBootstrap -Verbose:$false | Out-Null + Install-Module Selenium -Force -RequiredVersion '3.0.1' -Verbose:$false } - Import-Module Selenium -Force + Import-Module Selenium -Force -Version '3.0.1' -Verbose:$false } function Get-SeleniumModule4 { @@ -1436,11 +1442,11 @@ function Get-WebDriver { try { Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\chromeNewDriver.zip" }catch{ - + Write-Verbose $_.Exception.Message } # Expand archive and replace the old file Expand-Archive "$webDriversPath\chromeNewDriver.zip" -DestinationPath "$webDriversPath\tempchrome" -Force - Move-Item "$webDriversPath\tempchrome\chromedriver.exe" -Destination "$($webDriversPath)\chromedriver.exe" -Force + Move-Item "$webDriversPath\tempchrome\chromedriver-win64\chromedriver.exe" -Destination "$($webDriversPath)\chromedriver.exe" -Force # clean-up Remove-Item "$webDriversPath\chromeNewDriver.zip" -Force | Out-Null @@ -1452,7 +1458,7 @@ function Get-WebDriver { try { $edgeVersion = (Get-Item (Get-ItemProperty $edgeRegistryPath).'(Default)').VersionInfo.ProductVersion } catch { - + Write-Verbose $_.Exception.Message } # check which driver versions are installed $edgeDriverVersion = Get-LocalDriverVersion -pathToDriver $edgeDriverPath @@ -1477,7 +1483,11 @@ function Get-WebDriver { } # download the file - Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\edgeNewDriver.zip" + try { + Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\edgeNewDriver.zip" + } catch{ + Write-Verbose $_.Exception.Message + } # epand archive and replace the old file Expand-Archive "$webDriversPath\edgeNewDriver.zip" -DestinationPath "$webDriversPath\tempedge" -Force @@ -1516,7 +1526,7 @@ function Start-SeleniumModule { ) if($WebDriver -eq "Edge"){ Get-RunAsUserModule - Import-Module -Name RunAsUser + Import-Module -Name RunAsUser -Verbose:$false $scriptblock = { Import-Module Selenium $WebDriverPath = "C:\temp\EasyWarrantyCheck\WebDrivers" @@ -1535,14 +1545,18 @@ function Start-SeleniumModule { ) }) $driver = New-Object OpenQA.Selenium.Edge.EdgeDriver($EdgeService, $edgeOptions) Start-Sleep -Seconds 3 + return $driver } $invokeasuser = invoke-ascurrentuser -scriptblock $scriptblock -UseWindowsPowerShell -CaptureOutput + Write-Verbose "Driver Invoked : $invokeasuser" $process = "msedgedriver.exe" $commandLine = Get-CimInstance Win32_Process -Filter "name = '$process'" | select CommandLine + Write-Verbose "msedgedriver.exe process : $commandLine" # Regular expression pattern to match port number $portPattern = '--port=(\d+)' if ($commandLine -match $portPattern) { $driverportnumber = $matches[1] + Write-Verbose "Driver Port Number : $driverportnumber" } else { Write-Output "Port number not found." } @@ -1557,6 +1571,7 @@ function Start-SeleniumModule { "debuggerAddress" = $debuggerAddress }) # Connect to the existing Edge session + return $driver = New-Object OpenQA.Selenium.Remote.RemoteWebDriver($remoteAddress, $options) } if($WebDriver -eq "Chrome"){ @@ -1606,6 +1621,7 @@ function Stop-SeleniumModule { foreach ($process in $headlessEdgeProcesses) { $processID = $process.ProcessId if ($processID -ne $null) { + Write-Verbose "Stopping : $processID" Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue | Out-null } else { } @@ -1618,16 +1634,17 @@ function Stop-SeleniumModule { foreach ($process in $driverProcesses) { $processID = $process.ProcessId if ($processID -ne $null) { + Write-Verbose "Stopping : $processID" Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue | Out-null } else { } } - Remove-Module Selenium -Force -ErrorAction SilentlyContinue | Out-null + Remove-Module Selenium -Force -ErrorAction SilentlyContinue -Verbose:$false | Out-null } if($WebDriver -eq "Chrome"){ $driver.quit() - Remove-Module Selenium -Force -ErrorAction SilentlyContinue | Out-null + Remove-Module Selenium -Force -ErrorAction SilentlyContinue -Verbose:$false | Out-null } } @@ -1722,9 +1739,9 @@ function Write-WarrantyRegistry{ if (-not (Test-Path $RegistryPath)) { # Create the registry key if it doesn't exist New-Item -Path $RegistryPath -Force -ErrorAction SilentlyContinue | Out-Null - Write-Debug "Registry key created successfully." + Write-Verbose "Registry key created successfully." } else { - Write-Debug "Registry key already exists." + Write-Verbose "Registry key already exists." } if($Warrantystart){ New-ItemProperty -Path $RegistryPath -Name "WarrantyStart" -PropertyType String -Value $Warrantystart -Force -ErrorAction SilentlyContinue | Out-Null diff --git a/Private/Helpers/Get-RunAsUserModule.ps1 b/Private/Helpers/Get-RunAsUserModule.ps1 index 09832ed..94e75e3 100644 --- a/Private/Helpers/Get-RunAsUserModule.ps1 +++ b/Private/Helpers/Get-RunAsUserModule.ps1 @@ -11,15 +11,15 @@ function Get-RunAsUserModule { #> try { - Set-ExecutionPolicy Bypass -scope Process -Force -ErrorAction SilentlyContinue | Out-Null - }catch{ + Set-ExecutionPolicy Bypass -Scope Process -Force -ErrorAction SilentlyContinue | Out-Null + } catch { } - Import-Module PowerShellGet - $RunAsUser = Get-Module -Name RunAsUser -ListAvailable + Import-Module PowerShellGet -Verbose:$false + $RunAsUser = Get-Module -Name RunAsUser -ListAvailable | Where-Object { $_.Version -eq '2.4.0' } if (-not $RunAsUser) { - Get-PackageProvider -Name "nuGet" -ForceBootstrap | Out-Null - Install-Module RunAsUser -Force + Get-PackageProvider -Name "nuGet" -ForceBootstrap -Verbose:$false | Out-Null + Install-Module RunAsUser -Force -RequiredVersion '2.4.0' -Verbose:$false } - Import-Module RunAsUser -Force -} \ No newline at end of file + Import-Module RunAsUser -Force -Version '2.4.0' -Verbose:$false +} diff --git a/Private/Helpers/Get-SeleniumModule.ps1 b/Private/Helpers/Get-SeleniumModule.ps1 index d20f8e1..b8735a0 100644 --- a/Private/Helpers/Get-SeleniumModule.ps1 +++ b/Private/Helpers/Get-SeleniumModule.ps1 @@ -15,11 +15,11 @@ function Get-SeleniumModule { }catch{ } - Import-Module PowerShellGet - $seleniumModule = Get-Module -Name Selenium -ListAvailable + Import-Module PowerShellGet -Verbose:$false + $seleniumModule = Get-Module -Name Selenium -ListAvailable | Where-Object { $_.Version -eq '3.0.1' } if (-not $seleniumModule) { - Get-PackageProvider -Name "nuGet" -ForceBootstrap | Out-Null - Install-Module Selenium -Force + Get-PackageProvider -Name "nuGet" -ForceBootstrap -Verbose:$false | Out-Null + Install-Module Selenium -Force -RequiredVersion '3.0.1' -Verbose:$false } - Import-Module Selenium -Force + Import-Module Selenium -Force -Version '3.0.1' -Verbose:$false } \ No newline at end of file diff --git a/Private/Helpers/Get-WebDriver.ps1 b/Private/Helpers/Get-WebDriver.ps1 index c2c1cb1..1fc0f8e 100644 --- a/Private/Helpers/Get-WebDriver.ps1 +++ b/Private/Helpers/Get-WebDriver.ps1 @@ -106,11 +106,11 @@ function Get-WebDriver { try { Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\chromeNewDriver.zip" }catch{ - + Write-Verbose $_.Exception.Message } # Expand archive and replace the old file Expand-Archive "$webDriversPath\chromeNewDriver.zip" -DestinationPath "$webDriversPath\tempchrome" -Force - Move-Item "$webDriversPath\tempchrome\chromedriver.exe" -Destination "$($webDriversPath)\chromedriver.exe" -Force + Move-Item "$webDriversPath\tempchrome\chromedriver-win64\chromedriver.exe" -Destination "$($webDriversPath)\chromedriver.exe" -Force # clean-up Remove-Item "$webDriversPath\chromeNewDriver.zip" -Force | Out-Null @@ -122,7 +122,7 @@ function Get-WebDriver { try { $edgeVersion = (Get-Item (Get-ItemProperty $edgeRegistryPath).'(Default)').VersionInfo.ProductVersion } catch { - + Write-Verbose $_.Exception.Message } # check which driver versions are installed $edgeDriverVersion = Get-LocalDriverVersion -pathToDriver $edgeDriverPath @@ -147,7 +147,11 @@ function Get-WebDriver { } # download the file - Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\edgeNewDriver.zip" + try { + Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\edgeNewDriver.zip" + } catch{ + Write-Verbose $_.Exception.Message + } # epand archive and replace the old file Expand-Archive "$webDriversPath\edgeNewDriver.zip" -DestinationPath "$webDriversPath\tempedge" -Force diff --git a/Private/Helpers/Start-SeleniumModule.ps1 b/Private/Helpers/Start-SeleniumModule.ps1 index bb733f1..2dc3989 100644 --- a/Private/Helpers/Start-SeleniumModule.ps1 +++ b/Private/Helpers/Start-SeleniumModule.ps1 @@ -24,7 +24,7 @@ function Start-SeleniumModule { ) if($WebDriver -eq "Edge"){ Get-RunAsUserModule - Import-Module -Name RunAsUser + Import-Module -Name RunAsUser -Verbose:$false $scriptblock = { Import-Module Selenium $WebDriverPath = "C:\temp\EasyWarrantyCheck\WebDrivers" @@ -43,14 +43,18 @@ function Start-SeleniumModule { ) }) $driver = New-Object OpenQA.Selenium.Edge.EdgeDriver($EdgeService, $edgeOptions) Start-Sleep -Seconds 3 + return $driver } $invokeasuser = invoke-ascurrentuser -scriptblock $scriptblock -UseWindowsPowerShell -CaptureOutput + Write-Verbose "Driver Invoked : $invokeasuser" $process = "msedgedriver.exe" $commandLine = Get-CimInstance Win32_Process -Filter "name = '$process'" | select CommandLine + Write-Verbose "msedgedriver.exe process : $commandLine" # Regular expression pattern to match port number $portPattern = '--port=(\d+)' if ($commandLine -match $portPattern) { $driverportnumber = $matches[1] + Write-Verbose "Driver Port Number : $driverportnumber" } else { Write-Output "Port number not found." } @@ -65,6 +69,7 @@ function Start-SeleniumModule { "debuggerAddress" = $debuggerAddress }) # Connect to the existing Edge session + return $driver = New-Object OpenQA.Selenium.Remote.RemoteWebDriver($remoteAddress, $options) } if($WebDriver -eq "Chrome"){ diff --git a/Private/Helpers/Stop-SeleniumModule.ps1 b/Private/Helpers/Stop-SeleniumModule.ps1 index 93f567b..e219aeb 100644 --- a/Private/Helpers/Stop-SeleniumModule.ps1 +++ b/Private/Helpers/Stop-SeleniumModule.ps1 @@ -33,6 +33,7 @@ function Stop-SeleniumModule { foreach ($process in $headlessEdgeProcesses) { $processID = $process.ProcessId if ($processID -ne $null) { + Write-Verbose "Stopping : $processID" Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue | Out-null } else { } @@ -45,15 +46,16 @@ function Stop-SeleniumModule { foreach ($process in $driverProcesses) { $processID = $process.ProcessId if ($processID -ne $null) { + Write-Verbose "Stopping : $processID" Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue | Out-null } else { } } - Remove-Module Selenium -Force -ErrorAction SilentlyContinue | Out-null + Remove-Module Selenium -Force -ErrorAction SilentlyContinue -Verbose:$false | Out-null } if($WebDriver -eq "Chrome"){ $driver.quit() - Remove-Module Selenium -Force -ErrorAction SilentlyContinue | Out-null + Remove-Module Selenium -Force -ErrorAction SilentlyContinue -Verbose:$false | Out-null } } \ No newline at end of file diff --git a/Private/Helpers/Write-WarrantyRegistry.ps1 b/Private/Helpers/Write-WarrantyRegistry.ps1 index 34abcf2..3c0a5fa 100644 --- a/Private/Helpers/Write-WarrantyRegistry.ps1 +++ b/Private/Helpers/Write-WarrantyRegistry.ps1 @@ -36,9 +36,9 @@ function Write-WarrantyRegistry{ if (-not (Test-Path $RegistryPath)) { # Create the registry key if it doesn't exist New-Item -Path $RegistryPath -Force -ErrorAction SilentlyContinue | Out-Null - Write-Debug "Registry key created successfully." + Write-Verbose "Registry key created successfully." } else { - Write-Debug "Registry key already exists." + Write-Verbose "Registry key already exists." } if($Warrantystart){ New-ItemProperty -Path $RegistryPath -Name "WarrantyStart" -PropertyType String -Value $Warrantystart -Force -ErrorAction SilentlyContinue | Out-Null diff --git a/Public/Get-Warranty.ps1 b/Public/Get-Warranty.ps1 index d53e11d..afb31de 100644 --- a/Public/Get-Warranty.ps1 +++ b/Public/Get-Warranty.ps1 @@ -26,6 +26,7 @@ function Get-Warranty { # Web Driver mode, Edge or Chrome ( Edge Beta Support ) [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [Parameter(Mandatory = $false, ParameterSetName = 'CentralNinja')] [ValidateSet('Chrome', 'Edge')] [String]$Seleniumdrivermode = 'Chrome', @@ -36,7 +37,7 @@ function Get-Warranty { # Enable Registry Storing [Parameter(Mandatory = $false, ParameterSetName = 'Default')] [bool]$EnableRegistry = $true, - + # Registry Path [Parameter(Mandatory = $false, ParameterSetName = 'Default')] [String]$RegistryPath = 'HKLM:\SOFTWARE\RMMCustomInfo\', @@ -46,6 +47,7 @@ function Get-Warranty { [bool]$ForceUpdate = $false, # Custom Machine Details, available in both sets + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] [Parameter(Mandatory = $false, ParameterSetName = 'CentralNinja')] [String]$Serial = 'Automatic', diff --git a/Public/Get-WarrantyAsus.ps1 b/Public/Get-WarrantyAsus.ps1 index 32fe7b8..acd02d0 100644 --- a/Public/Get-WarrantyAsus.ps1 +++ b/Public/Get-WarrantyAsus.ps1 @@ -47,13 +47,14 @@ function Get-WarrantyAsus { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Start a new browser session with headless mode try{ $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true }catch{ + Write-Verbose $_.Exception.Message $WarObj = [PSCustomObject]@{ 'Serial' = $Serial 'Warranty Product name' = $null @@ -64,7 +65,7 @@ function Get-WarrantyAsus { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Navigate to the warranty check URL @@ -79,7 +80,7 @@ function Get-WarrantyAsus { $submitcheckcookiesButton = $driver.FindElementByXPath("//div[@class='btn-asus btn-ok btn-read-ck' and @aria-label='Accept']") $submitcheckcookiesButton.Click() } catch{ - + Write-Verbose $_.Exception.Message } $checkPrivacyButton = $driver.FindElementById("checkPrivacy") $checkPrivacyButton.Click() diff --git a/Public/Get-WarrantyDell.ps1 b/Public/Get-WarrantyDell.ps1 index dae0322..c6b661b 100644 --- a/Public/Get-WarrantyDell.ps1 +++ b/Public/Get-WarrantyDell.ps1 @@ -47,13 +47,14 @@ function Get-WarrantyDell { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Start a new browser session with headless mode try{ $driver = Start-SeleniumModule -WebDriver $Seleniumdrivermode -Headless $true }catch{ + Write-Verbose $_.Exception.Message $WarObj = [PSCustomObject]@{ 'Serial' = $Serial 'Warranty Product name' = $null @@ -64,7 +65,7 @@ function Get-WarrantyDell { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } # Navigate to the warranty check URL diff --git a/Public/Get-WarrantyEdsys.ps1 b/Public/Get-WarrantyEdsys.ps1 index 2666593..cdddb03 100644 --- a/Public/Get-WarrantyEdsys.ps1 +++ b/Public/Get-WarrantyEdsys.ps1 @@ -38,7 +38,7 @@ function Get-WarrantyEdsys { try { $response = Invoke-WebRequest -Uri $url -Method Post -Body $payload -ContentType "application/x-www-form-urlencoded" -UseBasicParsing }catch{ - Write-Host $($_.Exception.Message) + Write-Verbose $_.Exception.Message } if($response){ # Output the response diff --git a/Public/Get-WarrantyHP.ps1 b/Public/Get-WarrantyHP.ps1 index bfaac12..368e171 100644 --- a/Public/Get-WarrantyHP.ps1 +++ b/Public/Get-WarrantyHP.ps1 @@ -39,6 +39,7 @@ function Get-WarrantyHP { } catch { if ($PSCmdlet.ParameterSetName -eq 'Default') { + Write-Verbose $_.Exception.Message Write-Host "###########################" Write-Host "WARNING" Write-Host "$($browserinstalled.software) not detected" @@ -62,7 +63,7 @@ function Get-WarrantyHP { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } catch { @@ -77,7 +78,7 @@ function Get-WarrantyHP { 'Product Image' = $null 'Warranty URL' = $null } - Remove-Module Selenium + Remove-Module Selenium -Verbose:$false return $warObj } } @@ -103,13 +104,13 @@ function Get-WarrantyHP { $errorMsgElement = $driver.FindElementByClassName("errorTxt") } catch { - Write-Debug "No Product Model required" + Write-Verbose "No Product Model required" } if ($null -ne $errorMsgElement -and $null -ne $SystemSKU) { # Error message found Write-Host "Using SystemSKU input" - Write-Debug "Need Product ID" + Write-Verbose "Need Product ID" $productField = $driver.FindElementById("product-number inputtextPN") $productField.SendKeys($SystemSKU) $submitButton = $driver.FindElementById("FindMyProductNumber") @@ -123,7 +124,7 @@ function Get-WarrantyHP { elseif ($null -ne $errorMsgElement -and $global:ServerMode -ne $true) { # Error message found Write-Host "Searching for additional SystemSKU......." - Write-Debug "Need Product ID" + Write-Verbose "Need Product ID" # Define the registry path $regPath = "HKLM:\HARDWARE\DESCRIPTION\System\BIOS" # Get the value of "SystemSKU" if it exists