diff --git a/Get-PC/Private/Get-Devices.ps1 b/Get-PC/Private/Get-Devices.ps1 index b8d96ae..9b0da6c 100644 --- a/Get-PC/Private/Get-Devices.ps1 +++ b/Get-PC/Private/Get-Devices.ps1 @@ -312,39 +312,34 @@ function FindUSBDevice { $deviceID -match '(?<=PID_)(....)' | Out-Null $p = $Matches[0] } - for ($i = 0; $i -lt $usbIDs.Count; $i++) { - if ($usbIDs[$i] -match $vid){ - - if($usbIDs[$i][0] -eq "`t"){ - - } - else{ - - $man = ($usbIDs[$i] -split ' ') - $man = $man[2..$man.count] -join ' ' - - for ($y = $i+1; $y -lt $usbIDs.Count; $y++) { - if($usbIDs[$y][0] -ne "`t"){ - return @{ - Manufacturer = $man - Description = $null - } - } - if($usbIDs[$y] -match $p){ - $dev = ($usbIDs[$y] -split ' ') - $dev = $dev[2..$dev.count] -join ' ' - return @{ - Manufacturer = $man - Description = $dev - } - } + for ($i = 0; $i -lt $usbIDs.Count; $i++) { + if (-not ($usbIDs[$i] -match $vid)){ continue } - } + if($usbIDs[$i][0] -eq "`t"){ continue } + + $man = ($usbIDs[$i] -split ' ') + $man = $man[2..$man.count] -join ' ' + + for ($y = $i+1; $y -lt $usbIDs.Count; $y++) { + if($usbIDs[$y][0] -ne "`t"){ return @{ Manufacturer = $man Description = $null } } + if($usbIDs[$y] -match $p){ + $dev = ($usbIDs[$y] -split ' ') + $dev = $dev[2..$dev.count] -join ' ' + return @{ + Manufacturer = $man + Description = $dev + } + } + + } + return @{ + Manufacturer = $man + Description = $null } } } end { diff --git a/Get-PC/Private/PCMonitor.ps1 b/Get-PC/Private/PCMonitor.ps1 index 35bb166..a70d88c 100644 --- a/Get-PC/Private/PCMonitor.ps1 +++ b/Get-PC/Private/PCMonitor.ps1 @@ -14,7 +14,7 @@ function Invoke-PCMonitor { foreach ($comp in $comps) { Write-Progress -Activity "Initializing sessions" -Status $comp -PercentComplete ($dogs.Length/$comps.Length) $dog = [WatchDog]::new($comp) - $null = $dog.Update() + Write-Host $dog.ReportChange() $dogs += $dog } Write-Progress -Activity "Initializing sessions" -Completed diff --git a/Get-PC/Private/SHSPrinter.ps1 b/Get-PC/Private/SHSPrinter.ps1 index 7a257d9..80c1dcb 100644 --- a/Get-PC/Private/SHSPrinter.ps1 +++ b/Get-PC/Private/SHSPrinter.ps1 @@ -80,7 +80,7 @@ function Get-SHSPrinter { $CMDB_IP = "*CMDB Mismatch - check CMDB*" } - if ($result.IP -ne $null) { + if ($null -ne $result.IP) { Write-Progress -Activity "Getting printer details for $name" -Status 'Connecting to printer' -PercentComplete 30 -ParentId 1 diff --git a/Get-PC/Private/UninstallProgram.ps1 b/Get-PC/Private/UninstallProgram.ps1 index 127e998..86ce06f 100644 --- a/Get-PC/Private/UninstallProgram.ps1 +++ b/Get-PC/Private/UninstallProgram.ps1 @@ -26,8 +26,12 @@ function Invoke-UninstallProgram ($Computer) { foreach ($item in $selection) { Write-Host "Uninstalling $($apps[$item].Name)" $res = $apps[$item].Uninstall() - if ($res.ReturnValue) { - Write-Warning "$appname failed to uninstall from $Computer with ReturnValue $($res.ReturnValue)" + switch ($res) { + 0 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $Computer" } + 1641 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $Computer"; Write-Warning "Restarting $Computer" } + 3010 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $Computer"; Write-Warning "Please restart $Computer to finish uninstall" } + 3011 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $Computer"; Write-Warning "Please restart $Computer to finish uninstall" } + default { Write-Warning "$appname failed to uninstall from $Computer with ReturnValue $($res.ReturnValue)" } } } } diff --git a/Get-PC/Public/Get-PC.ps1 b/Get-PC/Public/Get-PC.ps1 index acff26d..8f0910f 100644 --- a/Get-PC/Public/Get-PC.ps1 +++ b/Get-PC/Public/Get-PC.ps1 @@ -275,7 +275,7 @@ begin { $comp,$msg = Get-Hostname $comp Write-Progress -Activity "Get-PC flags processing" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1 - if ($msg -and -not $SHSPrinter) { + if ($msg -and -not $SHSPrinter -and -not $SHSPrinterWeb) { if ($SoundEnabled) { $oopsSoundPath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\gamblecore.wav' (New-Object Media.SoundPlayer $oopsSoundPath).Play() diff --git a/Get-PC/patchnotes.txt b/Get-PC/patchnotes.txt index 24312c2..1ecca13 100644 --- a/Get-PC/patchnotes.txt +++ b/Get-PC/patchnotes.txt @@ -1,3 +1,8 @@ +Patch: 2024-1-17 +-Fix SHSPrinterWeb bug with site domain names e.g. sagh.int.samhealth.net +-Add Better result code handling in UninstallProgram +-Add Monitor now reports the initial state of monitored workstations + Patch: 2024-12-13 -Add Powershell input pipeline support, unoptimized -Add CMDB fields now hold Spark warnings rather than printing to console in SCCM and normal queries