Updated all progress bars, added patchnotes preview, and minor fixes

This commit is contained in:
Zachary Gorman 2024-09-18 11:15:13 -07:00
parent cd21de83f5
commit 2dfa1f20af
16 changed files with 498 additions and 405 deletions

View file

@ -20,6 +20,7 @@ function Get-AppDiff {
# extra apps that we need to consider downloading
$apps = Get-Apps $pc
Write-Progress -Activity "Filtering out standard apps from $pc" -Status 'Removing version numbers and loading reference' -PercentComplete 10 -ParentId 1
$apps = Remove-Version $apps
# Open example file
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\ExpectedApps.json'
@ -30,7 +31,10 @@ function Get-AppDiff {
$exclude = $example + $ignore
$output = @()
# Finds each app that isn't in the example
$appi = 0
foreach ( $app in $apps ) {
$appi++
Write-Progress -Activity "Filtering out standard apps from $pc" -Status "Checking $($app.DisplayName)" -PercentComplete (($appi * 90 / $apps.Length) + 10) -ParentId 1
$skip = $false
foreach ($notapp in $GetPCNotInstalledApps) {
if ($app.DisplayName -match $notapp) {
@ -42,9 +46,10 @@ function Get-AppDiff {
$output += $app
}
Write-Progress -Activity "Filtering out standard apps from $pc" -Status "Checking $app" -PercentComplete (($appi * 90 / $apps.Length) + 10) -ParentId 1
if($TableView){
$output | Out-GridView -Title "Get-PC Apps - $ComputerName"
$output | Out-GridView -Title "Get-PC Apps - $pc"
}
else{
Write-Output $output

View file

@ -1,7 +1,9 @@
Function Get-Apps($ComputerName, $TableView) {
Write-Progress -Activity "Getting apps for $ComputerName" -Status 'Querying SCCM apps' -PercentComplete 10 -ParentId 1
$86apps, $64apps = Get-SCCM_Apps $ComputerName
Write-Progress -Activity "Getting apps for $ComputerName" -Status 'Querying local apps' -PercentComplete 30 -ParentId 1
#Checks if local computer
if ($ComputerName -eq $env:COMPUTERNAME) {
$localapps = Get-Package -ProviderName Programs -IncludeWindowsInstaller |
@ -20,6 +22,7 @@
}
}
Write-Progress -Activity "Getting apps for $ComputerName" -Status 'Combining apps from SCCM' -PercentComplete 50 -ParentId 1
$out = $86apps + $64apps
$apps = @()
foreach ($item in $out) {
@ -36,6 +39,7 @@
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
$apps += $a
Write-Progress -Activity "Getting apps for $ComputerName" -Status 'Combining apps from local query' -PercentComplete 75 -ParentId 1
# Grab apps that are only returned by local query
if ($out) {
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
@ -55,6 +59,7 @@
else {
Write-Output $apps
}
Write-Progress -Activity "Getting apps for $ComputerName" -Completed
}
function Copy-Property ($From, $To) {

View file

@ -67,7 +67,7 @@ function BatchInvokesProgressBar {
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((10/100) * 100)}
3 { Write-Progress -Activity "Querying online computers" -PercentComplete ((20/100)*100)}
4 { Write-Progress -Activity "Querying SCCM for offline computers" -PercentComplete ((75/100) * 100)}
5 { Write-Progress -Activity "Querying CMDB for computers not in SCCM" -PercentComplete ((75/100) * 100)}
5 { Write-Progress -Activity "Querying CMDB for computers not in SCCM" -PercentComplete ((85/100) * 100)}
Default {}
}

View file

@ -2,25 +2,33 @@ function Get-CMDBFallback {
param (
$comp
)
Write-Progress -Activity "CMDB Fallback $name" -Status 'Querying Spark! for Name match' -PercentComplete 30 -ParentId 1
## $cmdbData = Get-LANDeskCMDBItem -name $comp
$cmdbData = Search-ISMBO -bo cis -filter "Name eq '$comp'" -RawFilter
if(!$cmdbData){
Write-Progress -Activity "CMDB Fallback $name" -Status 'Attempting to extract asset tag from name' -PercentComplete 40 -ParentId 1
if($comp.Length -gt 5){
$asset = $comp[-5..-1] -join ""
#$asset = $comp[-5..-1] -join ""
# Match the first set of 5 digits that don't have any digits after it until end of line
if ($comp -match "\d{5}(?!\d)*$") { $asset = $Matches[0]}
## $cmdbData = Get-LANDeskCMDBItem -AssetTag $asset
$cmdbData = Search-ISMBO -bo cis -filter "AssetTag eq '$asset'" -RawFilter
if($cmdbData){
$comp = $cmdbData.values.Title
Write-Progress -Activity "CMDB Fallback $name" -Status "Asset tag found, checking connection to $comp" -PercentComplete 70 -ParentId 1
if(Test-Connection $comp){
Write-Progress -Activity "CMDB Fallback $name" -Status "Rerunning get-pc with new name $comp" -PercentComplete 85 -ParentId 1
$getpcData = get-pc $comp
Write-Progress -Activity "CMDB Fallback $name" -Completed
return $getpcData
}
}
}
}
Write-Progress -Activity "CMDB Fallback $name" -Status 'Parsing Spark! results' -PercentComplete 60 -ParentId 1
$status = $cmdbData.Status
if(!$status){
$status = 'No CMDB/SCCM Record Located'
@ -55,6 +63,7 @@ function Get-CMDBFallback {
# $locationData = $cmdbData.values._SHSCalcLocationString
# }
if($cmdbData.CIType -eq 'MobileDevice'){
Write-Progress -Activity "CMDB Fallback $name" -Status 'Querying Spark! for mobile device details' -PercentComplete 85 -ParentId 1
$cmdbData = Get-ISMBO -bo ci__mobiledevices -RecID $cmdbData.RecId
@ -116,8 +125,11 @@ function Get-CMDBFallback {
# }
if ($cmdbData.CIType -eq "Computer"){
Write-Progress -Activity "CMDB Fallback $name" -Status 'Querying Spark! for computer details' -PercentComplete 70 -ParentId 1
$cmdbData = Get-ISMBO -BO ci__computers -recid $cmdbData.Recid
Write-Progress -Activity "CMDB Fallback $name" -Status 'Querying Spark! for memory details' -PercentComplete 80 -ParentId 1
$memoryData = Search-ISMBO -bo frs_CIComponent__memorys -Filter "ParentLink_RecId eq '$($cmdbData.RecId)'" -RawFilter
Write-Progress -Activity "CMDB Fallback $name" -Status 'Querying Spark! for disk usage details' -PercentComplete 90 -ParentId 1
$diskData = Search-ISMBO -bo frs_cicomponent__logicalstorages -Filter "ParentLink_RecId eq '$($cmdbdata.recid)'" -Rawfilter
if ($memoryData){
$MemoryTotal = ($Memorydata.Memorysize | measure-object -sum).sum
@ -162,6 +174,7 @@ function Get-CMDBFallback {
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $cmdbData.SHS_IsVendorPC
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
}
Write-Progress -Activity "CMDB Fallback $name" -Completed
return $obj
}

View file

@ -4,6 +4,7 @@ function Get-Devices {
[Parameter(Mandatory=$false)][string]$status
)
try {
Write-Progress -Activity "Getting devices for $name" -Status 'Collecting USB devices' -PercentComplete 10 -ParentId 1
if ($status -eq "Online") {
$usb = Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
} else {
@ -11,7 +12,10 @@ function Get-Devices {
}
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
$usbi = 0
foreach($item in $usb){
$usbi++
Write-Progress -Activity "Getting devices for $name" -Status "Parsing USB Devices ($usbi/$($usb.Length)" -PercentComplete (($usbi * (80-10) / $usb.Length )+10) -ParentId 1
$friendlyNames = FindUSBDevice -deviceID $item.'DeviceID\SerialNumber'.ToString()
if($friendlyNames){
@ -29,6 +33,7 @@ function Get-Devices {
}
}
}
Write-Progress -Activity "Getting devices for $name" -Status 'Sorting out duplicate devices' -PercentComplete 80 -ParentId 1
$usb = $usb | Sort-Object Manufacturer,Description
for ($i = 0; $i -lt $usb.Count - 1; $i++) {
if($usb[$i].Manufacturer -eq $usb[$i+1].Manufacturer -and $usb[$i].Description -eq $usb[$i+1].Description){
@ -45,6 +50,7 @@ function Get-Devices {
}
if ($status -eq 'Online') {
Write-Progress -Activity "Getting devices for $name" -Status 'Getting monitors' -PercentComplete 90 -ParentId 1
$monitors = @()
$monitors += Get-Monitor $comp | Select-Object Manufacturer,@{N='Description';E={$_.Model}},@{N="DeviceID\SerialNumber";E={$_.SerialNumber}},AttachedComputer,ActivePort
$monitors | Add-Member -NotePropertyName Type -NotePropertyValue Monitor
@ -74,6 +80,7 @@ function Get-Devices {
$out = @()
Write-Progress -Activity "Getting devices for $name" -Status 'Finalizing' -PercentComplete 100 -ParentId 1
foreach($item in ($monitors + $usb)){
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
$out += $item

View file

@ -2,6 +2,7 @@ function Get-DevicesUnplugged {
param (
[string]$comp
)
Write-Progress -Activity "Getting devices for $name" -Status 'Collecting USB devices' -PercentComplete 10 -ParentId 1
if ($comp -eq $env:COMPUTERNAME) {
$usb += Get-PnpDevice -Status UNKNOWN | Select-Object @{N="Description";E={$_.FriendlyName}},@{N="DeviceID\SerialNumber";E={$_.InstanceID}} | Add-Member -NotePropertyName Manufacturer -NotePropertyValue 'Unknown' -PassThru
} else {
@ -11,7 +12,10 @@ function Get-DevicesUnplugged {
}
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
$usbi = 0
foreach($item in $usb){
$usbi++
Write-Progress -Activity "Getting devices for $name" -Status "Parsing USB Devices ($usbi/$($usb.Length)" -PercentComplete (($usbi * (90-10) / $usb.Length )+10) -ParentId 1
$friendlyNames = FindUSBDevice -deviceID $item.'DeviceID\SerialNumber'.ToString()
if($friendlyNames){
@ -29,6 +33,7 @@ function Get-DevicesUnplugged {
}
}
}
Write-Progress -Activity "Getting devices for $name" -Status 'Sorting out duplicate devices' -PercentComplete 90 -ParentId 1
$usb = $usb | Sort-Object Manufacturer,Description
for ($i = 0; $i -lt $usb.Count - 1; $i++) {
if($usb[$i].Manufacturer -eq $usb[$i+1].Manufacturer -and $usb[$i].Description -eq $usb[$i+1].Description){

View file

@ -1,77 +1,97 @@
function Get-Hostname ([string]$name) {
Write-Progress -Activity "Resolving hostname for $name" -Status 'SCCM Asset Tag Lookup' -PercentComplete 10 -ParentId 1
$errMsg = ''
if ($name.Length -eq 5) {
$res = Get-AssetConversion $name
if ($res) { return $res,'' }
else { $errMsg += "$name Asset Tag not in SMBIOS`n" }
if ($res) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $res,''
} else { $errMsg += "$name Asset Tag not in SMBIOS`n" }
# We don't check CMDB asset tags here because they often resolve to
# something other than the hostname, like the asset tag itself
}
Write-Progress -Activity "Resolving hostname for $name" -Status 'IP Address resolution' -PercentComplete 20 -ParentId 1
# Regex to match IP Address brought to you by https://stackoverflow.com/a/36760050
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
$res = Resolve-DnsName $name
if ($res -and $res.NameHost -and ($res.NameHost -match "([^.]*)\.int\.samhealth\.net")) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $Matches[0],''
} else {
$errMsg += "$name IP Address couldn't be resolved to hostname`n"
}
}
Write-Progress -Activity "Resolving hostname for $name" -Status 'SCCM Serial Number lookup' -PercentComplete 30 -ParentId 1
if ($name.Length -eq 7) {
$res = Get-ServiceTagConversion $name
if ($res) { return $res,'' }
try {
$cmdbData = Search-ISMBO -bo cis -filter "SerialNumber eq '$name'" -RawFilter
} catch { $cmdbData = $null }
if ( $cmdbData ) { return $cmdbData.Name, '' }
else { $errMsg += "$name Service Tag not found in SCCM nor CMDB`n"}
if ($res) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $res,''
} else { $errMsg += "$name Service Tag not found in SCCM`n"}
}
Write-Progress -Activity "Resolving hostname for $name" -Status 'SCCM MAC Address lookup' -PercentComplete 40 -ParentId 1
# Regex to match MAC Address brought to you by https://stackoverflow.com/a/4260512
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
$res = Get-SCCM_PCFromMAC $name
if ($res) { return $res,'' }
else { $errMsg += "$name MAC Address not found in SCCM`n"}
if ($res) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $res,''
} else { $errMsg += "$name MAC Address not found in SCCM`n"}
}
# Last resort checks
$sccmMatches = Get-SCCM_HostnameMatch $name
Write-Progress -Activity "Resolving hostname for $name" -Status 'SCCM Hostname match' -PercentComplete 50 -ParentId 1
$SCCMMatches = Get-SCCM_HostnameMatch $name
if ($SCCMMatches -and $SCCMMatches.Count -lt 2) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $SCCMMatches,''
} elseif (!$SCCMMatches) { $errMsg += "No SCCM name match found`n" }
elseif ($SCCMMatches.Count -ge 2) { $errMsg += "Many SCCM name matches found`n" }
# CMDB check should be absolute last resort
Write-Progress -Activity "Resolving hostname for $name" -Status 'CMDB General search' -PercentComplete 60 -ParentId 1
$cmdbMatches = Find-ISMBO -bo cis -SearchQuery $name
if ($cmdbMatches -and $cmdbMatches.Count -lt 2) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $cmdbMatches.Name,''
} elseif (!$cmdbMatches) { $errMsg += "No CMDB name match found`n" }
elseif ($cmdbMatches.Count -ge 2) {
# Try more specific queries
# Asset tag
Write-Progress -Activity "Resolving hostname for $name" -Status 'CMDB Asset Tag search' -PercentComplete 70 -ParentId 1
if ($name.Length -eq 5) {
try {
$cmdbData = Search-ISMBO -bo cis -Filter "AssetTag eq '$name'" -RawFilter
} catch { $cmdbData = $null }
if ( $cmdbData ) {
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
else { $errMsg += "CMDB name associated with Asset tag $name doesn't resolve to IP Address"}
if (Resolve-DnsName $cmdbData.Name) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $cmdbData.Name,''
} else { $errMsg += "CMDB name associated with Asset tag $name doesn't resolve to IP Address"}
} else { $errMsg += "Asset tag not in CMDB" }
}
Write-Progress -Activity "Resolving hostname for $name" -Status 'CMDB MAC Address search' -PercentComplete 80 -ParentId 1
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
try {
$cmdbData = Search-ISMBO -bo cis -Filter "MACAddress eq '$name'" -RawFilter
} catch { $cmdbData = $null }
if ( $cmdbData ) {
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
else { $errMsg += "CMDB name associated with MAC Address $name doesn't resolve to IP Address"}
if (Resolve-DnsName $cmdbData.Name) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $cmdbData.Name,''
} else { $errMsg += "CMDB name associated with MAC Address $name doesn't resolve to IP Address"}
} else { $errMsg += "MAC Address not in CMDB" }
}
# Serial number
Write-Progress -Activity "Resolving hostname for $name" -Status 'CMDB Serial Number search' -PercentComplete 80 -ParentId 1
try {
$cmdbData = Search-ISMBO -bo cis -Filter "SerialNumber eq '$name'" -RawFilter
} catch { $cmdbData = $null }
if ( $cmdbData ) {
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
else { $errMsg += "CMDB name associated with Serial Number $name doesn't resolve to IP Address"}
if (Resolve-DnsName $cmdbData.Name) {
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
return $cmdbData.Name,''
} else { $errMsg += "CMDB name associated with Serial Number $name doesn't resolve to IP Address"}
} else { $errMsg += "Serial Number not in CMDB" }
$errMsg += "Many CMDB matches found`n"
}

View file

@ -1,12 +1,11 @@
function Find-NextPrinterName($printerPrefix){
<#if($printerPrefix -eq $null){
if($printerPrefix -eq $null){
$printerPrefix = Read-Host "Printer Prefix"
}
#>
$printerNames = @()
$printerPrefix = Read-Host "Printer Prefix"
$printerNumber = 1
$printerName = ''
@ -14,32 +13,25 @@
$domains = @('','.gsrmc.int.samhealth.net','.avery.int.samhealth.net','.sagh.int.samhealth.net','.snlh.int.samhealth.net','.slch.int.samhealth.net','.spch.int.samhealth.net')
for ($i=0; $i -lt 5; $i++){
#Write-Host $printerNumber
while($hit -eq $true){
$hit = $false
$printerName = "{0}{1:d2}" -f ($printerPrefix,$printerNumber)
#Write-Host $printerName
Write-Progress -Activity "Searching for next printer name" -Status "($($i+1)/5) $printerName" -PercentComplete $printerNumber
$di = 0
foreach ($domain in $domains){
$printerHost = "$printerName$domain"
#Write-Host $printerHost
$testHost = Resolve-DnsName $printerHost
if($null -ne $testHost) {
$hit = $true
}
}
#Write-Host $printerHost
#Write-HOst $nslookup
if($hit -eq $true){
$printerNumber++
if($null -ne $testHost) { $hit = $true }
$di++
}
if($hit -eq $true){ $printerNumber++ }
}
$printerNames += $printerName
$printerNumber++
$hit = $true
}
Write-Progress -Activity "Searching for next printer name" -Completed
#Write-Host "$printerName"
return $printerNames

View file

@ -8,19 +8,20 @@
"Accept-Encoding" = "gzip, deflate, br"
}
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 10
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Network Adapters, Storage Disks, and Chassis" -PercentComplete 10
try {$win32_networkadapterconfiguration = Get-CimInstance -Class win32_networkadapterconfiguration} catch {$win32_networkadapterconfiguration = $null} #| MAC Address,
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace,
try {$win32_SystemEnclosure = Get-CimInstance -ClassName Win32_SystemEnclosure} catch {$win32_SystemEnclosure = $null} #| Asset Tag
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 20
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Bitlocker, Current User, RAM, Serial Number, and OS Version" -PercentComplete 20
try {$bitlocker = manage-bde -status C:} catch {$bitlocker = $null} # | Bitlocker Status
try {$PCInfo = get-computerinfo} catch {$PCInfo = $null}
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 30
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Printers, Imprivata, and Stoarge Disk Type" -PercentComplete 30
try {$physicalDisk = Get-PhysicalDisk} catch {$physicalDisk = $null} # | Disk Type
try {$win32_printer = (Get-CimInstance -ClassName win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || ' }
catch{ $win32_printer = $null} # | Printers
try {$imprivataRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent} catch {$imprivataRegEntry = $null}
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 40
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Kiosk Type and TPM status" -PercentComplete 40
try {$kioskRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SHSCustom} catch {$kioskRegEntry = $null}
try {$win32_tpm = Get-CimInstance -Namespace root\cimv2\security\microsofttpm -Class win32_tpm} catch{$win32_tpm = $null} # | TPM
@ -36,7 +37,7 @@
}
#>
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 50
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Citrix Version, CPU Type, and Parsing Network Data" -PercentComplete 50
$CitrixViewer = "C:\Program Files (X86)\Citrix\ICA Client\CDViewer.exe"
#$LastUser = Get-ChildItem -Path C:\Users -Directory -Force -Exclude Public,Default,'Default User','All Users' | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 3 # | Last Users
try {$CPU = (Get-CimInstance -ClassName Win32_processor ).Name } catch {$CPU = $null}
@ -78,7 +79,7 @@
}
}
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 60
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Parsing Last Users and Total RAM" -PercentComplete 60
#Collecting most recent users from the registry
$lastuser = @()
$profiles = Get-CimInstance -Class Win32_UserProfile
@ -130,7 +131,7 @@
#Drive Type
$DriveType = $physicalDisk.MediaType
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 70
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Parsing Disk Usage and Computer Info" -PercentComplete 70
#Free Harddrive Space
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
$free = $compFreeSpace[0]
@ -182,7 +183,7 @@
}
$osBuild = $PCInfo.OSBuildNumber
$osBuild = "Vers $osVer | Build #$osBuild"
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 80
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Parsing Printers, Imprivata type, and TPM status" -PercentComplete 80
#Printers
$printers = $win32_printer# ($win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || '
if(!$printers){
@ -238,7 +239,7 @@
$tpmStatus = "Off"
}
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 90
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Parsing Citrix Version, and Chassis Type" -PercentComplete 90
#Citrix Version
if( !(Test-path $CitrixViewer)){
@ -309,7 +310,7 @@
}
$timeout = 10
Write-Progress -Activity "Retrieving data from online computers" -Status "$Env:COMPUTERNAME | Querying Spark!... Timeout $($timeout)s" -PercentComplete 95
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=Name eq '$ENV:COMPUTERNAME'&`$top=1&`$skip=0"
try {
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $Headers -TimeoutSec $timeout
@ -337,7 +338,7 @@
$LocationData = $LocationData -join ' | '
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 100
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -PercentComplete 100
#Output
# $i++ | ProgressBar $i $comp 'Generating Output' $NumberofComputers $PCID
$obj = New-Object -TypeName PSObject
@ -369,6 +370,7 @@
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $cmdbData.SHS_IsVendorPC
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
}
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Completed
return $obj
}

View file

@ -11,7 +11,7 @@ function Invoke-PrinterPurge ($printer) {
for ($i = 0; $i -lt $comps.Length; $i += 1) {
$comp = $comps[$i]
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -PercentComplete (100*$i / $comps.Length) -CurrentOperation "$comp $i/$($comps.Length)"
Write-Progress -Activity "Dispatching Remove-Printer Jobs for $printer" -PercentComplete (100*$i / $comps.Length) -CurrentOperation "$comp $i/$($comps.Length)" -ParentId 1
if ($comp -like "*EPIC*") { continue }

View file

@ -3,12 +3,16 @@ function get-resources {
param ( $pc )
$sBlock = {
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting disk data" -PercentComplete 10 -ParentId 1
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace
$obj = New-Object -TypeName PSObject
# Get system information
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting OS data" -PercentComplete 16 -ParentId 1
$sysInfo = Get-WmiObject -Class Win32_OperatingSystem
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting processor data" -PercentComplete 33 -ParentId 1
$sysProc = Get-WmiObject -Class Win32_Processor
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting memory data" -PercentComplete 50 -ParentId 1
$sysMem = Get-WmiObject -Class Win32_PhysicalMemory
$sysOS = $sysInfo.Caption
@ -23,12 +27,15 @@ function get-resources {
$sysTotalMem = $sysMem.Capacity / 1GB
}
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting processor usage" -PercentComplete 66 -ParentId 1
# Get processor usage
$procUsage = [math]::Round((Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue)
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting memory usage" -PercentComplete 83 -ParentId 1
# Get memory usage
$memUsage = [Math]::Round((1 - (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue/($sysTotalMem*1GB/1MB))*100,1)
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting network adapter data" -PercentComplete 100 -ParentId 1
# Get Physical Network Adapter information
$netAdapters = Get-NetAdapter -physical | Where-Object status -eq 'up'
@ -48,6 +55,7 @@ function get-resources {
$obj | Add-Member -MemberType NoteProperty -Name 'freeDisk' -Value $freeDisk
$obj | Add-Member -MemberType NoteProperty -Name 'maxDisk' -Value $maxDisk
Write-Progress -Activity "Getting resource data for $pc" -Completed
return $obj
}
$output = @()

View file

@ -5,9 +5,7 @@ $SCCMNAMESPACE="root\sms\site_100"
Function Get-SCCMQuery {
param (
[string]$comp,
[int]$NumberofComputers,
[int]$PCID
[string]$comp
)
if(!(Test-Connection -ComputerName $comp -Count 1)){
@ -18,6 +16,7 @@ Function Get-SCCMQuery {
$compStatus = "Online"
}
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Checking if disabled in AD' -PercentComplete 5 -ParentId 1
if(get-module -ListAvailable -Name 'ActiveDirectory'){
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
if($adTest){
@ -26,7 +25,7 @@ Function Get-SCCMQuery {
}
$i = 0
$i++ | ProgressBar $i $comp "SCCM Last Hardware Scan" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Last Hardware Scan' -PercentComplete 10 -ParentId 1
$FindLastHardwareScanSCCM = Get-SCCMLastHardwareScan $comp
if(!$FindLastHardwareScanSCCM){
$props = [Ordered]@{
@ -54,38 +53,38 @@ Function Get-SCCMQuery {
return $obj
}
$i++; i++ | ProgressBar $i $comp "Last User SCCM" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Last User Logon' -PercentComplete 15 -ParentId 1
$LastUserSCCM = Get-SCCMLastUserLogOnQuery $comp
$i++; i++ | ProgressBar $i $comp "SCCM IP Query" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for IP Address' -PercentComplete 20 -ParentId 1
$FindIPSCCM = Get-SCCMIPQuery $comp
$i++; i++ | ProgressBar $i $comp "Find Model SCCM" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Model' -PercentComplete 25 -ParentId 1
$CompModelSCCM = Get-SCCMFindModelQuery $comp
$i++; i++ | ProgressBar $i $comp "SCCM Bios Version" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Bios Version' -PercentComplete 30 -ParentId 1
$FindBiosVerSCCM = Get-SCCMBiosVerQuery $comp
$i++; i++ | ProgressBar $i $comp "SCCM HDD/SSD Space" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for storage space' -PercentComplete 35 -ParentId 1
$CompFreeSpaceSCCMGB = Get-SCCMFindFreeSpaceQuery $comp
$i++; i++ | ProgressBar $i $comp "SCCM RAM" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for RAM' -PercentComplete 40 -ParentId 1
$FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp
$i++ | ProgressBar $i $comp "SCCM Asset Tag" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Asset Tag' -PercentComplete 45 -ParentId 1
$FindAssetTagSCCM = Get-SCCMFindAssetTagQuery $comp
$i++; i++ | ProgressBar $i $comp "SCCM Service Tag" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Service Tag' -PercentComplete 50 -ParentId 1
$FindServiceTagSCCM = Get-SCCMServiceTagQuery $comp
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for OS Name' -PercentComplete 55 -ParentId 1
$i++; i++ | ProgressBar $i $comp "SCCM OS Name" $NumberofComputers $PCID
$FindOSNameSCCM = Get-SCCMFindOSNameQuery $comp
$i++; i++ | ProgressBar $i $comp "SCCM OS Architecture" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for OS Architecture' -PercentComplete 60 -ParentId 1
$FindOSArchSCCM = Get-SCCMFindOSArch $comp
$i++; i++ | ProgressBar $i $comp "SCCM OS Build" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for OS Build' -PercentComplete 65 -ParentId 1
$FindOSBuild = Get-SCCMFindOSBuild $comp
$i++; i++ | ProgressBar $i $comp "SCCM Encryption" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Encryption' -PercentComplete 70 -ParentId 1
$FindEncryptionSCCM = Get-SCCMFindEncryption $comp
$i++ | ProgressBar $i $comp "SCCM Last Boot Up Time" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Last boot time' -PercentComplete 75 -ParentId 1
$FindLastBootUpTimeSCCM = Get-SCCMLastBootUpTime $comp
$i++ | ProgressBar $i $comp "SCCM Printers" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Printers' -PercentComplete 80 -ParentId 1
$FindPCPrinterSCCM = Get-SCCMPCPrinter $comp
$i++; i++ | ProgressBar $i $comp "SCCM MACAddress" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for MAC address' -PercentComplete 85 -ParentId 1
$FindMACAddressSCCM = Get-SCCMFindMACAddress $comp
$i++ | ProgressBar $i $comp "SCCM Chassis Type" $NumberofComputers $PCID
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Chassis Type' -PercentComplete 90 -ParentId 1
$FindChassisTypeSCCM = Get-SCCMChassisType($comp)
if($FindAssetTagSCCM -is [array]){
Write-Warning "Dupe record in SCCM - $comp"
@ -93,9 +92,8 @@ Function Get-SCCMQuery {
<#Get-CMDBFallback $comp#>
}
<#$cmdbData = Get-CMDBData $comp $FindAssetTagSCCM
$MDBLcmdblocation = Get-Cocation $cmdbData
#>
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for CMDB data' -PercentComplete 95 -ParentId 1
$cmdbData = Search-ISMBO -bo cis -Filter "Name eq $comp" -RawFilter
if($FindLastHardwareScanSCCM){
Write-Host "`n`nPulling cached SCCM data for $comp." -ForegroundColor Yellow
@ -125,12 +123,12 @@ Function Get-SCCMQuery {
}
$obj = New-Object -TypeName PSObject -Property $props
<#if($cmdbData.values.ConfigurationItem._SHSDELAsset -eq 'True'){
if($cmdbData.values.ConfigurationItem._SHSDELAsset -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $delInfo.Owner
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $delInfo.Vendor
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
} #>
}
return $obj
}

View file

@ -10,21 +10,18 @@
function Get-SHSPrinter {
param (
[string[]]$printers
[string]$printer
)
begin {
Write-Progress -Activity "Getting printer details for $name" -Status 'Getting IP Address' -PercentComplete 10 -ParentId 1
$snmp = New-Object -ComObject olePrn.OleSNMP
}
process {
foreach ($printer in $printers) {
#Gets the printer ip and full domain name
$result = Get-PrinterIP $printer
#CMDB Data
Write-Progress -Activity "Getting printer details for $name" -Status 'Getting CMDB data' -PercentComplete 20 -ParentId 1
# $cmdbRecord = Get-LANDeskCMDBItem -Name $printer
$cmdbRecord = Search-ISMBO -BO cis -filter "Name eq '$Printer'" -RawFilter
@ -40,7 +37,8 @@ function Get-SHSPrinter {
if ($Loc -eq 'SHS_Floor') {
$(if ($cmdbRecord.$Loc -match '-') { $cmdbRecord.$Loc.split('-')[-1] + " Floor" } else { $cmdbRecord.$Loc })
} elseif (![string]::IsNullOrEmpty($cmdbRecord.$Loc)){
}
elseif (![string]::IsNullOrEmpty($cmdbRecord.$Loc)) {
$cmdbRecord.$Loc
}
}
@ -84,6 +82,7 @@ function Get-SHSPrinter {
if ($result.IP -ne $null) {
Write-Progress -Activity "Getting printer details for $name" -Status 'Connecting to printer' -PercentComplete 30 -ParentId 1
$printerip = $result.IP
$domainName = $result.Path
@ -97,6 +96,7 @@ function Get-SHSPrinter {
#opens snmp connection to the printer
$snmp.open($printerip, 'public', 2, 3000)
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for MAC address' -PercentComplete 40 -ParentId 1
# Start of MAC
$pMAC = $SNMP.get(".1.3.6.1.2.1.2.2.1.6.2")
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
@ -105,26 +105,31 @@ function Get-SHSPrinter {
$MAC = $MAC -join ':'
#End of MAC
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for model' -PercentComplete 50 -ParentId 1
# MODEL
try { $model = $snmp.Get('.1.3.6.1.2.1.25.3.2.1.3.1') } catch { $model = $null }
# IF IT HAS A MODEL NAME...
if ($model) {
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for color' -PercentComplete 60 -ParentId 1
# COLOR
# might want to check on this one
try { if ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -match 'Toner|Cartridge|ink') { $color = 'Yes' } else { $color = 'No' } } catch { $color = 'No' }
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for trays' -PercentComplete 70 -ParentId 1
# TRAYS
try { $trays = $($snmp.GetTree('.1.3.6.1.2.1.43.8.2.1.13') | ? { $_ -notlike 'print*' }) -join ';' } catch { $trays = $null }
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for serial numbers' -PercentComplete 80 -ParentId 1
# SERIAL
try { $serial = $snmp.Get('.1.3.6.1.2.1.43.5.1.1.17.1') } catch { $serial = $null }
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for page count' -PercentComplete 90 -ParentId 1
#PAGECOUNT
try { $pagecount = $snmp.Get('.1.3.6.1.2.1.43.10.2.1.4.1.1') } catch { $page = $null }
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for model features' -PercentComplete 100 -ParentId 1 -Id 2
##### FEATURES, NAME
switch -Regex ($model) {
'^sharp' {
@ -140,12 +145,17 @@ function Get-SHSPrinter {
#End of MAC
}
'^zebra' {
Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for name' -PercentComplete 10 -ParentId 2
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 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 }
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.200.19.5.0') } catch { $serial = $null }
# try { $status = $snmp.Get('.1.3.6.1.4.1.10642.200.4.1.0') } catch { $status = $null }
$model = "Zebra $model"
Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for status' -PercentComplete 90 -ParentId 2
#STATUS
$uri = $domainName
$html = Invoke-WebRequest -uri $uri
@ -158,17 +168,25 @@ function Get-SHSPrinter {
$err = $split[1] -split '<'
$status = $status + ' ' + $err[0]
Write-Progress -Activity "Getting zebra features from $name" -Completed
}
'^lexmark' {
Write-Progress -Activity "Getting lexmark features from $name" -Status 'Querying for name' -PercentComplete 50 -ParentId 2
try { $name = $snmp.Get('.1.3.6.1.4.1.641.1.5.7.6.0').toupper() } catch { $name = $null }
Write-Progress -Activity "Getting lexmark features from $name" -Completed
}
'^ricoh' {
Write-Progress -Activity "Getting ricoh features from $name" -Status 'Querying for name' -PercentComplete 50 -ParentId 2
try { $name = $snmp.Get('.1.3.6.1.4.1.367.3.2.1.7.3.5.1.1.2.1.1').toupper() } catch { $name = $null }
Write-Progress -Activity "Getting ricoh features from $name" -Completed
}
'^hp' {
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for name' -PercentComplete 5 -ParentId 2
try { $name = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.5.46.0').toupper() } catch { $name = $null }
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for status' -PercentComplete 10 -ParentId 2
try { $status = $snmp.Get('.1.3.6.1.4.1.11.2.3.9.1.1.3.0') } catch { $status = $null }
if ($MAC -eq '') {
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for MAC Address' -PercentComplete 15 -ParentId 2
$pMAC = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.1.12.1.2.5')
$MAC = ($pMAC -split " ")[-1]
$MAC = ($MAC -replace '(..)', '$1:').trim(':')
@ -181,31 +199,37 @@ function Get-SHSPrinter {
HP Toner Cur: 1.3.6.1.2.1.43.11.1.1.9.1.1
HP Toner Max: 1.3.6.1.2.1.43.11.1.1.8.1.1
#>
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color' -PercentComplete 20 -ParentId 2
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.1') -split ' ')[0] } catch { $tonerColor = $null }
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner level' -PercentComplete 25 -ParentId 2
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.1') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.1') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax } catch { $toner = $null }
[int]$toner = $toner * 100
$supplies = "$tonerColor" + ":$toner% "
if ($color -eq 'Yes') {
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color levels' -PercentComplete 35 -ParentId 2
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
$supplies += "$tonerColor" + ":$toner% "
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color levels' -PercentComplete 50 -ParentId 2
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.3') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.3') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.3') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
$supplies += "$tonerColor" + ":$toner% "
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color levels' -PercentComplete 65 -ParentId 2
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.4') -split ' ')[0] } catch { $tonerColor = $null }
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.4') } catch { $tonerLvl = $null }
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.4') } catch { $tonerMax = $null }
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
$supplies += "$tonerColor" + ":$toner% "
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for maintenance kit status' -PercentComplete 80 -ParentId 2
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6') -split ' ')[0] } catch { $tonerColor = $null }
if ($supplyName -contains 'Fuser' -or $supplyName -contains 'Maint') {
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6') } catch { $supplyPartNumber = $null }
@ -241,6 +265,7 @@ function Get-SHSPrinter {
}
}
else {
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for maintenance kit status' -PercentComplete 80 -ParentId 2
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0] } catch { $supplyName = $null }
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') } catch { $supplyPartNumber = $null }
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
@ -257,12 +282,16 @@ function Get-SHSPrinter {
}
}
Write-Progress -Activity "Getting hp features from $name" -Completed
}
'^muratec' {
Write-Progress -Activity "Getting muratec features from $name" -Status 'Querying for name' -PercentComplete 30 -ParentId 2
try { $name = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.5.46.0').toupper() } catch { $name = $null }
Write-Progress -Activity "Getting muratec features from $name" -Status 'Querying for status' -PercentComplete 60 -ParentId 2
try { $status = $snmp.Get('.1.3.6.1.2.1.43.16.5.1.2.1.1') } catch { $status = $null }
# Start of MAC
Write-Progress -Activity "Getting muratec features from $name" -Status 'Querying for MAC address' -PercentComplete 90 -ParentId 2
$pMAC = $SNMP.get('.1.3.6.1.4.1.4322.101.1.2.1.5.2.1.1.3.1')
Write-Host $pMAC
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
@ -270,14 +299,15 @@ function Get-SHSPrinter {
}
$MAC = $MAC -join ':'
#End of MAC
Write-Progress -Activity "Getting muratec features from $name" -Completed
}
default {
}
}
}#end switch -Regex ($model)
#if ($model -like 'SHARP*') {}
}
}#end if ($model)
}
else {
$status = "Offline"
@ -311,11 +341,9 @@ function Get-SHSPrinter {
}
$obj = New-Object -TypeName PSObject -Property $props
$snmp.close()
Write-Progress -Activity "Getting printer details for $name" -Completed
return $obj
}
}
}#end if ($printerIp)
if ($CMDB_IP) {
$offlineIP = 'CMDB IP - ' + $CMDB_IP
}
@ -343,7 +371,6 @@ function Get-SHSPrinter {
return $obj
}
}
function Get-PrinterIP {

View file

@ -8,6 +8,7 @@
Write-Warning 'Active Drirectory Thick Client is required for this function'
return
}
Write-Progress -Activity "Getting user data for $name" -Status 'Querying AD for user data' -PercentComplete 30 -ParentId 1
if($user -match "^[\d\.]+$"){
$UserInfo = Get-ADUser -Filter { EmployeeID -eq $user } -properties *
$user = $UserInfo.SamAccountName
@ -38,6 +39,8 @@
}
$manager = $UserInfo.Manager.Split("=,")[1]
Write-Progress -Activity "Getting user data for $name" -Status 'Querying SCCM for LastLogon data' -PercentComplete 80 -ParentId 1
$computerSCCM = Get-SCCM_UserLastLoggedOn $user
$computerList = $computerSCCM -join ", "
$props = [ordered]@{

View file

@ -27,6 +27,19 @@ $getPCWrappedPath = '\\int.samhealth.net\files\TEAM\SHSISDesktopSolutions\Powers
Write-Host "`nGet-PC Module Version $Version [$devStage] Loaded." -ForegroundColor Green
if ($Version -ne $deployedVersion) {
Write-Host 'New version of Get-PC is available. Please run Get-PC -Update' -ForegroundColor Yellow
if ($devStage -eq "Prod") {
if ($getPCProdBuildPath -match '^(.*)\\[^\\]+$') { $getPCPatchNotesPath = "$($Matches[1])\patchnotes.txt" }
}
elseif ($devStage -eq "Dev") {
if ($getPCDevBuildPath -match '^(.*)\\[^\\]+$') { $getPCPatchNotesPath = "$($Matches[1])\patchnotes.txt" }
}
$patchNotes = Get-Content $getPCPatchNotesPath
$msg = ''
foreach ($line in $patchNotes) {
if ($line -match '^\s*$') { break }
$msg += " $line`n"
}
Write-Host "$msg"
}
Write-Host "Enter 'Help Get-PC' for available commands.`n" -ForegroundColor Green
#endregion
@ -55,6 +68,7 @@ Function Get-PC {
-Monitor | monitors computers for changes in status
-NextPrinterName | generates next open printer name
-Orion | opens orion to the mac address of the pc
-PatchNotes | read the patch notes
-PCCleanup | removes temp files and inactive user profiles
-PCReboot | reboots computer
-PCRename | renames computer
@ -181,13 +195,9 @@ Function Get-PC {
if($locationSearch){
Write-Host 'Please enter a partial location like a room number.'
$searchInput = Read-Host 'Location'
if ($ComputerName[0]) { $searchInput = $ComputerName[0] }
else { $searchInput = Read-Host 'Location' }
Write-Host "Searching CMDB for $searchInput ..."
<# $ComputerName
if($ComputerName.count -gt 1){
Write-Host 'Can only search a single location at a time' -ForegroundColor Yellow
return
} #>
if($searchInput.ToCharArray().Length -lt 3){
Write-Host 'Location searches much contain more than 2 characters' -ForegroundColor Yellow
return
@ -206,6 +216,13 @@ Function Get-PC {
}
#Generates an available printer hostname. Useful for supplying a new hostname in new printer requests
if ($NextPrinterName) {
Find-NextPrinterName $ComputerName[0]
break
}
$charA = $ComputerName.ToCharArray()
if($charA -contains '*'){
if($charA -lt 4){
@ -231,10 +248,12 @@ Function Get-PC {
$getPCComputers = @() #List of computers that will get a batch query
$outPutArray = @() #For use near the end of the script to output to users screen in a specified format
$PCID = 1 #This is a helper variable for the progress bar
$PCID = 0 #This is a helper variable for the progress bar
$NumberofComputers = $ComputerName.Count
foreach ($comp in $ComputerName) {
$PCID++
Write-Progress -Activity "Get-PC flags processing" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
#Pulls user data from AD
if ($SHSUser) {
$user = Get-SHSUser $comp
@ -243,6 +262,7 @@ Function Get-PC {
}
$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 ($SoundEnabled) {
$oopsSoundPath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\gamblecore.wav'
@ -290,7 +310,6 @@ Function Get-PC {
#Pulls basic SNMP Data from printer $comp
if ($SHSPrinter) {
Write-Progress -Activity "Querying Printers" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
$printer = Get-SHSPrinter $comp
$outPutArray += $printer
$PCID++
@ -306,6 +325,7 @@ Function Get-PC {
#Grabs all hostnames that have the requested printer installed on it
if ($HostnamesByPrinter) {
Write-Progress -Activity "Hostnames by printer for $comp" -Status "Querying SCCM" -PercentComplete 50 -Id 1
$printers = HostnamesByPrinter $comp
$out = @()
foreach ($printer in $printers) {
@ -320,6 +340,7 @@ Function Get-PC {
else {
Write-Output $out
}
Write-Progress -Activity "Hostnames by printer for $comp" -Completed
continue
}
@ -328,12 +349,6 @@ Function Get-PC {
continue
}
#Generates an available printer hostname. Useful for supplying a new hostname in new printer requests
if ($NextPrinterName) {
Find-NextPrinterName $comp
break
}
if ($Wake) {
Invoke-Wake $comp
continue
@ -341,8 +356,9 @@ Function Get-PC {
#PING HERE - All commands after here either require the computer to be online or need to know
#------------------------------------------------------------------------------------------------------------------------------------------------------------------#
Write-Progress -Activity "Get-PC flags processing" -Status "Connecting to $comp ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
$Connection = Test-Connection -ComputerName $comp -Count 1
Write-Progress -Activity "Connecting to computers" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
#Write-Progress -Activity "Connecting to computers" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
if ($Connection) {
$compStatus = 'Online'
@ -599,7 +615,7 @@ Function Get-PC {
#checks to see if the computer is in AD or the disabled computers OU and warns the user
if (get-module -ListAvailable -Name 'ActiveDirectory') {
Write-Progress -Activity "Looking up computer in AD" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
Write-Progress -Activity "Get-PC flags processing" -Status "Looking up $comp in AD ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
if ($adTest) {
@ -609,35 +625,23 @@ Function Get-PC {
(New-Object Media.SoundPlayer $oopsSoundPath).Play()
}
}
Write-Progress -Activity "Looking up computer in AD" -Completed
}
#Direct SCCM Queries
if ( $SCCM ) {
$result = Get-SCCMQuery $comp $NumberofComputers $PCID
$PCID++
$outPutArray += $result
continue
}
else {
#Checks if local computer
if ($comp -eq $env:COMPUTERNAME) {
$result = Get-PCLocal $comp $NumberofComputers $PCID
#$PCID++
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
$outPutArray += $result
#$getPCComputers += $comp
}
else {
#$result = Get-PCRemote $comp $NumberofComputers $PCID
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
#$PCID++
#$outPutArray += $result
#Write-Output $result
$getPCComputers += $comp
}
}
if ($Orion) {
@ -645,6 +649,7 @@ Function Get-PC {
}
}
Write-Progress -Activity "Get-PC flags processing" -Completed -Id 1
# Monitor list of PCs for change in online status or
if ($Monitor) {
@ -683,7 +688,3 @@ Function Get-PC {
}
}
Function ProgressBar($Percent, $CurrentPC, $CurrentLocationText, $NumberofComputers, $CurrentPCNumber) {
Write-Progress -Activity "Scanning PC $CurrentPC ($CurrentPCNumber/$NumberofComputers)" -Status "Querying: $CurrentLocationText" -PercentComplete (($Percent / 29) * 100)
}

View file

@ -1,4 +1,11 @@
Hi, I'm the patch notes, nice to meet you!
These are the changes in the most recent update of Get-PC
Patch: 2024-09-18
-Add When update is announced, most recent patch notes are announced with it
-Add Patchnotes flag to the help readout so users know what's new
-Fix when reporting many IP addresses, now only displays ipv4
-Fix NextPrinterName now accepts input from parameters, not just the prompt
-Add More verbose progress bars!
Patch: 2024-09-13
-Fix Order of hostame resolution changed so it's more consistent with true hostname