diff --git a/Get-PC/Private/EnableComputer.ps1 b/Get-PC/Private/EnableComputer.ps1 index 53dea34..584ae98 100644 --- a/Get-PC/Private/EnableComputer.ps1 +++ b/Get-PC/Private/EnableComputer.ps1 @@ -1,13 +1,25 @@ function Invoke-EnableComputer ($comp) { - $site = switch -Regex ($comp) { - '^A' {'SAGH'} - '^L' {'SLCH'} - '^S' {'SNLH'} - '^P' {'SPCH'} - '^G(AV|CN|WN)' {'Avery'} - default {'GSRMC'} - } - $comp | Get-ADComputer | Enable-ADAccount -PassThru | Move-ADObject -TargetPath "OU=$site,OU=Samaritan Workstations,DC=int,DC=samhealth,DC=net" + # This if statement attempts to place a workstation at a location. Workstations + # that don't follow the old naming scheme with site indicators are just placed in + # the Samaritan Workstations OU. We could query to see if they are online and use + # the DNS servers to determine what site they are at, but that's too much trouble + # for now + $site = if ($comp -match "^([WL][0-9]{5})|(PACS)") { $null } else { + switch -Regex ($comp) { + '^A' {'SAGH'} + '^L' {'SLCH'} + '^S' {'SNLH'} + '^P' {'SPCH'} + '^G(AV|CN|WN)' {'Avery'} + '^G(?!AV|CN|WN)' {'GSRMC'} + default {$null} + } + } + if ($null -eq $site) { + $comp | Get-ADComputer | Enable-ADAccount -PassThru | Move-ADObject -TargetPath "OU=Samaritan Workstations,DC=int,DC=samhealth,DC=net" + } else { + $comp | Get-ADComputer | Enable-ADAccount -PassThru | Move-ADObject -TargetPath "OU=$site,OU=Samaritan Workstations,DC=int,DC=samhealth,DC=net" + } if (Get-ADUser -Filter "Name -like 'K_$comp'") { Write-Host -ForegroundColor Yellow "Kiosk account found. Please re-submit a kiosk request and re-kiosk $comp." } else { diff --git a/Get-PC/Private/PCLocal.ps1 b/Get-PC/Private/PCLocal.ps1 index b2f6870..2dd5a2c 100644 --- a/Get-PC/Private/PCLocal.ps1 +++ b/Get-PC/Private/PCLocal.ps1 @@ -311,7 +311,14 @@ $timeout = if ($SparkQueryTimeoutSec) {$SparkQueryTimeoutSec} else {5} Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Querying Spark! for location details. Timeout $($timeout)s" -PercentComplete 95 - $uri = "$Tenant/api/odata/businessobject/cis`?`$filter=AssetTag eq '$assetTag'&`$top=1&`$skip=0" + $uri = if ($assetTag -ne '') { + "$Tenant/api/odata/businessobject/cis`?`$filter=AssetTag eq '$assetTag'" + } elseif ($serviceTag){ + "$Tenant/api/odata/businessobject/cis`?`$filter=SerialNumber eq '$serviceTag'" + } else { + "$Tenant/api/odata/businessobject/cis`?`$filter=Name eq '$env:ComputerName'&`$top=1&`$skip=0" + } + try { $Query = Invoke-RestMethod -Method GET -uri $uri -headers $Headers -TimeoutSec $timeout if ($Query) { diff --git a/Get-PC/Private/SHSPrinter.ps1 b/Get-PC/Private/SHSPrinter.ps1 index fdb2d0f..3f8a3b7 100644 --- a/Get-PC/Private/SHSPrinter.ps1 +++ b/Get-PC/Private/SHSPrinter.ps1 @@ -193,8 +193,18 @@ $Headers = @{ try { $name = $snmp.Get('.1.3.6.1.4.1.10642.1.4.0').toupper() } catch { $name = $null } Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for model' -PercentComplete 30 -ParentId 2 try { $model = $snmp.Get('.1.3.6.1.4.1.10642.200.19.7.0').toupper() } catch { $model = $null } + Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for adapter type' -PercentComplete 40 -ParentId 2 + try { $adapter = $snmp.Get('.1.3.6.1.4.1.10642.20.10.20.5.2.1.5.3') } catch { $adapter = $null } + $adapterType = switch ($adapter) { + 1 { '(Ethernet)' } + 2 { '(WiFi)' } + default { $null } + } Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for MAC address' -PercentComplete 50 -ParentId 2 - try { $MAC = $snmp.Get('.1.3.6.1.4.1.10642.20.10.20.10.2.1.5.2').toupper() } catch { $MAC = $null } + $MAC = switch ($adapter) { + 2 { try { $snmp.Get('.1.3.6.1.4.1.10642.20.10.20.5.2.1.2.3') } catch { $null } } + default { try { $snmp.Get('.1.3.6.1.4.1.10642.20.10.20.5.2.1.2.2') } catch { $null } } + } Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for serial number' -PercentComplete 70 -ParentId 2 try { $serial = $snmp.Get('.1.3.6.1.4.1.10642.1.9.0') } catch { $serial = $null } if (!$serial) { try { $serial = $snmp.Get('.1.3.6.1.4.1.10642.200.19.5.0') } catch { $serial = $null } } @@ -211,6 +221,20 @@ $Headers = @{ 7 {'(PERMANENT)'} default {'(UNKNOWN)'} } + <# These settings seem to vary wildly in OID between models + $sensorType = try { $snmp.Get('.1.3.6.1.4.1.10642.2.851.1.4.3.0') } catch { 0 } + $sensorType = switch ($sensorType) { + 0 {'WEB'} + 1 {'MARK'} + default {'UNKNOWN'} + } + $mediaType = try { $snmp.Get('.1.3.6.1.4.1.10642.2.851.1.4.4.0') } catch { 1 } + $mediaType = switch ($mediaType) { + 0 {'CONTINUOUS'} + 1 {'NON-CONTINUOUS'} + default {'UNKNOWN'} + } + #> $model = "Zebra $model" Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for status' -PercentComplete 90 -ParentId 2 #STATUS @@ -218,8 +242,6 @@ $Headers = @{ $html = Invoke-WebRequest -uri $uri $raw = $html.rawcontent $raw -match '([A-Z])\w+<.F' | Out-Null - # Captures the first text between a > and < after "Status:" - #$raw -match 'Status:.*>(\w+)<.*>(\w+)<' | Out-Null $status = ($Matches[0] -split '<')[0] #split off error condition $raw -match 'RED>.+' | Out-Null @@ -388,7 +410,7 @@ $Headers = @{ Status = $status IP = "$printerip $ipconfig" DomainName = $domainName - MAC = $MAC + MAC = "$MAC $adapterType" Model = $model Serial = $serial #Comment = $comment diff --git a/Get-PC/Private/UninstallProgram.ps1 b/Get-PC/Private/UninstallProgram.ps1 index 4ecd2f8..faa2a24 100644 --- a/Get-PC/Private/UninstallProgram.ps1 +++ b/Get-PC/Private/UninstallProgram.ps1 @@ -27,11 +27,11 @@ function Invoke-UninstallProgram ($Computer) { Write-Host "Uninstalling $($apps[$item].Name)" $res = $apps[$item].Uninstall() switch ($res.ReturnValue) { - 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). See an MsiExec return value table for more information." } + 0 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $env:ComputerName" } + 1641 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $env:ComputerName"; Write-Warning "Restarting $env:ComputerName" } + 3010 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $env:ComputerName"; Write-Warning "Please restart $env:ComputerName to finish uninstall" } + 3011 { Write-Host "Successfully Uninstalled $($apps[$item].Name) from $env:ComputerName"; Write-Warning "Please restart $env:ComputerName to finish uninstall" } + default { Write-Warning "$appname failed to uninstall from $env:ComputerName with ReturnValue $($res.ReturnValue). See an MsiExec return value table for more information." } } } } diff --git a/Get-PC/patchnotes.txt b/Get-PC/patchnotes.txt index ab14d49..fd6e3c7 100644 --- a/Get-PC/patchnotes.txt +++ b/Get-PC/patchnotes.txt @@ -1,6 +1,11 @@ Patch -Fix Zebra printer statuses report correctly now -Fix ZD421 printers report Serial numbers correctly +-Update Enable now defualts workstations to the Samaritan Workstations OU rather than GSRMC +-Update Enable detects L12345 and PACS12345 and places them in the default rather than NLH and PCH OUs +-Fix UninstallProgram reports the hostname in the done message rather than blank +-Update Zebra printers report Ethernet or wifi. Detection method isn't officially documented by Zebra so could be faulty +-Fix PCLocal searches CMDB with the first non-null value in Asset Tag, Serial Number, and Name Patch 2025-5-28 -Update SCCMQueryBlock uses asset tag to query Spark!