Skip to content

Commit

Permalink
Remove debugging from module load
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrodksmith authored Mar 11, 2024
1 parent 265a151 commit ce9e25d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions Private/Helpers/Get-RunAsUserModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ function Get-RunAsUserModule {
} catch {

}
Import-Module PowerShellGet
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 -RequiredVersion '2.4.0'
Get-PackageProvider -Name "nuGet" -ForceBootstrap -Verbose:$false | Out-Null
Install-Module RunAsUser -Force -RequiredVersion '2.4.0' -Verbose:$false
}
Import-Module RunAsUser -Force -Version '2.4.0'
Import-Module RunAsUser -Force -Version '2.4.0' -Verbose:$false
}
8 changes: 4 additions & 4 deletions Private/Helpers/Get-SeleniumModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ function Get-SeleniumModule {
}catch{

}
Import-Module PowerShellGet
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 -RequiredVersion '3.0.1'
Get-PackageProvider -Name "nuGet" -ForceBootstrap -Verbose:$false | Out-Null
Install-Module Selenium -Force -RequiredVersion '3.0.1' -Verbose:$false
}
Import-Module Selenium -Force -Version '3.0.1'
Import-Module Selenium -Force -Version '3.0.1' -Verbose:$false
}
10 changes: 5 additions & 5 deletions Private/Helpers/Get-WebDriver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ function Get-WebDriver {
if (-not (Test-Path -Path $webDriversPath -PathType Container)) {
# Directory doesn't exist, create it
New-Item -Path $webDriversPath -ItemType Directory -Force | Out-Null
Write-Debug "Directory created successfully."
Write-Verbose "Directory created successfully."
} else {
Write-Debug "Directory already exists."
Write-Verbose "Directory already exists."
}
} catch {
Write-Host "An error occurred: $_"
Expand Down Expand Up @@ -106,7 +106,7 @@ function Get-WebDriver {
try {
Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\chromeNewDriver.zip"
}catch{
Write-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
}
# Expand archive and replace the old file
Expand-Archive "$webDriversPath\chromeNewDriver.zip" -DestinationPath "$webDriversPath\tempchrome" -Force
Expand All @@ -122,7 +122,7 @@ function Get-WebDriver {
try {
$edgeVersion = (Get-Item (Get-ItemProperty $edgeRegistryPath).'(Default)').VersionInfo.ProductVersion
} catch {
Write-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
}
# check which driver versions are installed
$edgeDriverVersion = Get-LocalDriverVersion -pathToDriver $edgeDriverPath
Expand Down Expand Up @@ -150,7 +150,7 @@ function Get-WebDriver {
try {
Invoke-WebRequest $downloadLink -OutFile "$webDriversPath\edgeNewDriver.zip"
} catch{
Write-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
}

# epand archive and replace the old file
Expand Down
8 changes: 4 additions & 4 deletions Private/Helpers/Start-SeleniumModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,15 +46,15 @@ function Start-SeleniumModule {
return $driver
}
$invokeasuser = invoke-ascurrentuser -scriptblock $scriptblock -UseWindowsPowerShell -CaptureOutput
Write-Debug "Driver Invoked : $invokeasuser"
Write-Verbose "Driver Invoked : $invokeasuser"
$process = "msedgedriver.exe"
$commandLine = Get-CimInstance Win32_Process -Filter "name = '$process'" | select CommandLine
Write-Debug "msedgedriver.exe process : $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-Debug "Driver Port Number : $driverportnumber"
Write-Verbose "Driver Port Number : $driverportnumber"
} else {
Write-Output "Port number not found."
}
Expand Down
4 changes: 2 additions & 2 deletions Private/Helpers/Stop-SeleniumModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Stop-SeleniumModule {
foreach ($process in $headlessEdgeProcesses) {
$processID = $process.ProcessId
if ($processID -ne $null) {
Write-Debug "Stopping : $processID"
Write-Verbose "Stopping : $processID"
Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue | Out-null
} else {
}
Expand All @@ -46,7 +46,7 @@ function Stop-SeleniumModule {
foreach ($process in $driverProcesses) {
$processID = $process.ProcessId
if ($processID -ne $null) {
Write-Debug "Stopping : $processID"
Write-Verbose "Stopping : $processID"
Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue | Out-null
} else {

Expand Down
4 changes: 2 additions & 2 deletions Private/Helpers/Test-SoftwareInstalled.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ foreach ($path in $registryPaths) {
$installed = Get-ItemProperty -Path $path | Where-Object { $_.DisplayName -eq $SoftwareName }
if ($installed) {
$version = $installed.DisplayVersion
Write-Debug "$SoftwareName version $version is installed."
Write-Verbose "$SoftwareName version $version is installed."
$result = [PSCustomObject]@{
Software = $SoftwareName
Installed = $true
Expand All @@ -41,7 +41,7 @@ Write-Host "WARNING"
Write-Host "$SoftwareName not detected"
Write-Host "This manufacturer currently requires $SoftwareName installed to check expiry"
Write-Host "###########################"
Write-Debug "$SoftwareName is not installed."
Write-Verbose "$SoftwareName is not installed."
$result = [PSCustomObject]@{
Software = $SoftwareName
Installed = $false
Expand Down
4 changes: 2 additions & 2 deletions Private/Helpers/Write-WarrantyRegistry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Public/Get-WarrantyAsus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +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-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
$WarObj = [PSCustomObject]@{
'Serial' = $Serial
'Warranty Product name' = $null
Expand All @@ -65,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
Expand All @@ -80,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-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
}
$checkPrivacyButton = $driver.FindElementById("checkPrivacy")
$checkPrivacyButton.Click()
Expand Down
6 changes: 3 additions & 3 deletions Public/Get-WarrantyDell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +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-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
$WarObj = [PSCustomObject]@{
'Serial' = $Serial
'Warranty Product name' = $null
Expand All @@ -65,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
Expand Down
2 changes: 1 addition & 1 deletion Public/Get-WarrantyEdsys.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
}
if($response){
# Output the response
Expand Down
12 changes: 6 additions & 6 deletions Public/Get-WarrantyHP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Get-WarrantyHP {
}
catch {
if ($PSCmdlet.ParameterSetName -eq 'Default') {
Write-Debug $_.Exception.Message
Write-Verbose $_.Exception.Message
Write-Host "###########################"
Write-Host "WARNING"
Write-Host "$($browserinstalled.software) not detected"
Expand All @@ -63,7 +63,7 @@ function Get-WarrantyHP {
'Product Image' = $null
'Warranty URL' = $null
}
Remove-Module Selenium
Remove-Module Selenium -Verbose:$false
return $warObj
}
catch {
Expand All @@ -78,7 +78,7 @@ function Get-WarrantyHP {
'Product Image' = $null
'Warranty URL' = $null
}
Remove-Module Selenium
Remove-Module Selenium -Verbose:$false
return $warObj
}
}
Expand All @@ -104,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")
Expand All @@ -124,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
Expand Down

0 comments on commit ce9e25d

Please sign in to comment.