Updated all progress bars, added patchnotes preview, and minor fixes
This commit is contained in:
parent
cd21de83f5
commit
2dfa1f20af
|
|
@ -20,6 +20,7 @@ function Get-AppDiff {
|
||||||
# extra apps that we need to consider downloading
|
# extra apps that we need to consider downloading
|
||||||
|
|
||||||
$apps = Get-Apps $pc
|
$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
|
$apps = Remove-Version $apps
|
||||||
# Open example file
|
# Open example file
|
||||||
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\ExpectedApps.json'
|
$lookupTablePath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\ExpectedApps.json'
|
||||||
|
|
@ -30,7 +31,10 @@ function Get-AppDiff {
|
||||||
$exclude = $example + $ignore
|
$exclude = $example + $ignore
|
||||||
$output = @()
|
$output = @()
|
||||||
# Finds each app that isn't in the example
|
# Finds each app that isn't in the example
|
||||||
|
$appi = 0
|
||||||
foreach ( $app in $apps ) {
|
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
|
$skip = $false
|
||||||
foreach ($notapp in $GetPCNotInstalledApps) {
|
foreach ($notapp in $GetPCNotInstalledApps) {
|
||||||
if ($app.DisplayName -match $notapp) {
|
if ($app.DisplayName -match $notapp) {
|
||||||
|
|
@ -42,9 +46,10 @@ function Get-AppDiff {
|
||||||
|
|
||||||
$output += $app
|
$output += $app
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Filtering out standard apps from $pc" -Status "Checking $app" -PercentComplete (($appi * 90 / $apps.Length) + 10) -ParentId 1
|
||||||
|
|
||||||
if($TableView){
|
if($TableView){
|
||||||
$output | Out-GridView -Title "Get-PC Apps - $ComputerName"
|
$output | Out-GridView -Title "Get-PC Apps - $pc"
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Write-Output $output
|
Write-Output $output
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
Function Get-Apps($ComputerName, $TableView) {
|
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
|
$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
|
#Checks if local computer
|
||||||
if ($ComputerName -eq $env:COMPUTERNAME) {
|
if ($ComputerName -eq $env:COMPUTERNAME) {
|
||||||
$localapps = Get-Package -ProviderName Programs -IncludeWindowsInstaller |
|
$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
|
$out = $86apps + $64apps
|
||||||
$apps = @()
|
$apps = @()
|
||||||
foreach ($item in $out) {
|
foreach ($item in $out) {
|
||||||
|
|
@ -36,6 +39,7 @@
|
||||||
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
|
$a.PSObject.TypeNames.Insert(0, 'GetPC.App')
|
||||||
$apps += $a
|
$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
|
# Grab apps that are only returned by local query
|
||||||
if ($out) {
|
if ($out) {
|
||||||
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
|
$localOnly = Compare-Object $localapps $out -Property DisplayName -PassThru | Where-Object {$_.SideIndicator -eq '<='}
|
||||||
|
|
@ -55,6 +59,7 @@
|
||||||
else {
|
else {
|
||||||
Write-Output $apps
|
Write-Output $apps
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Getting apps for $ComputerName" -Completed
|
||||||
}
|
}
|
||||||
function Copy-Property ($From, $To) {
|
function Copy-Property ($From, $To) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ function BatchInvokesProgressBar {
|
||||||
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((10/100) * 100)}
|
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((10/100) * 100)}
|
||||||
3 { Write-Progress -Activity "Querying online computers" -PercentComplete ((20/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)}
|
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 {}
|
Default {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,33 @@ function Get-CMDBFallback {
|
||||||
param (
|
param (
|
||||||
$comp
|
$comp
|
||||||
)
|
)
|
||||||
|
Write-Progress -Activity "CMDB Fallback $name" -Status 'Querying Spark! for Name match' -PercentComplete 30 -ParentId 1
|
||||||
|
|
||||||
## $cmdbData = Get-LANDeskCMDBItem -name $comp
|
## $cmdbData = Get-LANDeskCMDBItem -name $comp
|
||||||
$cmdbData = Search-ISMBO -bo cis -filter "Name eq '$comp'" -RawFilter
|
$cmdbData = Search-ISMBO -bo cis -filter "Name eq '$comp'" -RawFilter
|
||||||
|
|
||||||
if(!$cmdbData){
|
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){
|
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 = Get-LANDeskCMDBItem -AssetTag $asset
|
||||||
$cmdbData = Search-ISMBO -bo cis -filter "AssetTag eq '$asset'" -RawFilter
|
$cmdbData = Search-ISMBO -bo cis -filter "AssetTag eq '$asset'" -RawFilter
|
||||||
if($cmdbData){
|
if($cmdbData){
|
||||||
$comp = $cmdbData.values.Title
|
$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){
|
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
|
$getpcData = get-pc $comp
|
||||||
|
Write-Progress -Activity "CMDB Fallback $name" -Completed
|
||||||
return $getpcData
|
return $getpcData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Progress -Activity "CMDB Fallback $name" -Status 'Parsing Spark! results' -PercentComplete 60 -ParentId 1
|
||||||
$status = $cmdbData.Status
|
$status = $cmdbData.Status
|
||||||
if(!$status){
|
if(!$status){
|
||||||
$status = 'No CMDB/SCCM Record Located'
|
$status = 'No CMDB/SCCM Record Located'
|
||||||
|
|
@ -55,6 +63,7 @@ function Get-CMDBFallback {
|
||||||
# $locationData = $cmdbData.values._SHSCalcLocationString
|
# $locationData = $cmdbData.values._SHSCalcLocationString
|
||||||
# }
|
# }
|
||||||
if($cmdbData.CIType -eq 'MobileDevice'){
|
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
|
$cmdbData = Get-ISMBO -bo ci__mobiledevices -RecID $cmdbData.RecId
|
||||||
|
|
||||||
|
|
@ -116,8 +125,11 @@ function Get-CMDBFallback {
|
||||||
# }
|
# }
|
||||||
|
|
||||||
if ($cmdbData.CIType -eq "Computer"){
|
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
|
$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
|
$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
|
$diskData = Search-ISMBO -bo frs_cicomponent__logicalstorages -Filter "ParentLink_RecId eq '$($cmdbdata.recid)'" -Rawfilter
|
||||||
if ($memoryData){
|
if ($memoryData){
|
||||||
$MemoryTotal = ($Memorydata.Memorysize | measure-object -sum).sum
|
$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 Vendor PC' -Value $cmdbData.SHS_IsVendorPC
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
|
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "CMDB Fallback $name" -Completed
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ function Get-Devices {
|
||||||
[Parameter(Mandatory=$false)][string]$status
|
[Parameter(Mandatory=$false)][string]$status
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
|
Write-Progress -Activity "Getting devices for $name" -Status 'Collecting USB devices' -PercentComplete 10 -ParentId 1
|
||||||
if ($status -eq "Online") {
|
if ($status -eq "Online") {
|
||||||
$usb = Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
|
$usb = Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -11,7 +12,10 @@ function Get-Devices {
|
||||||
}
|
}
|
||||||
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
|
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
|
||||||
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
|
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
|
||||||
|
$usbi = 0
|
||||||
foreach($item in $usb){
|
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()
|
$friendlyNames = FindUSBDevice -deviceID $item.'DeviceID\SerialNumber'.ToString()
|
||||||
|
|
||||||
if($friendlyNames){
|
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
|
$usb = $usb | Sort-Object Manufacturer,Description
|
||||||
for ($i = 0; $i -lt $usb.Count - 1; $i++) {
|
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){
|
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') {
|
if ($status -eq 'Online') {
|
||||||
|
Write-Progress -Activity "Getting devices for $name" -Status 'Getting monitors' -PercentComplete 90 -ParentId 1
|
||||||
$monitors = @()
|
$monitors = @()
|
||||||
$monitors += Get-Monitor $comp | Select-Object Manufacturer,@{N='Description';E={$_.Model}},@{N="DeviceID\SerialNumber";E={$_.SerialNumber}},AttachedComputer,ActivePort
|
$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
|
$monitors | Add-Member -NotePropertyName Type -NotePropertyValue Monitor
|
||||||
|
|
@ -74,6 +80,7 @@ function Get-Devices {
|
||||||
|
|
||||||
$out = @()
|
$out = @()
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting devices for $name" -Status 'Finalizing' -PercentComplete 100 -ParentId 1
|
||||||
foreach($item in ($monitors + $usb)){
|
foreach($item in ($monitors + $usb)){
|
||||||
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
||||||
$out += $item
|
$out += $item
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ function Get-DevicesUnplugged {
|
||||||
param (
|
param (
|
||||||
[string]$comp
|
[string]$comp
|
||||||
)
|
)
|
||||||
|
Write-Progress -Activity "Getting devices for $name" -Status 'Collecting USB devices' -PercentComplete 10 -ParentId 1
|
||||||
if ($comp -eq $env:COMPUTERNAME) {
|
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
|
$usb += Get-PnpDevice -Status UNKNOWN | Select-Object @{N="Description";E={$_.FriendlyName}},@{N="DeviceID\SerialNumber";E={$_.InstanceID}} | Add-Member -NotePropertyName Manufacturer -NotePropertyValue 'Unknown' -PassThru
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -11,7 +12,10 @@ function Get-DevicesUnplugged {
|
||||||
}
|
}
|
||||||
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
|
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
|
||||||
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
|
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
|
||||||
|
$usbi = 0
|
||||||
foreach($item in $usb){
|
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()
|
$friendlyNames = FindUSBDevice -deviceID $item.'DeviceID\SerialNumber'.ToString()
|
||||||
|
|
||||||
if($friendlyNames){
|
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
|
$usb = $usb | Sort-Object Manufacturer,Description
|
||||||
for ($i = 0; $i -lt $usb.Count - 1; $i++) {
|
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){
|
if($usb[$i].Manufacturer -eq $usb[$i+1].Manufacturer -and $usb[$i].Description -eq $usb[$i+1].Description){
|
||||||
|
|
|
||||||
|
|
@ -1,77 +1,97 @@
|
||||||
function Get-Hostname ([string]$name) {
|
function Get-Hostname ([string]$name) {
|
||||||
|
Write-Progress -Activity "Resolving hostname for $name" -Status 'SCCM Asset Tag Lookup' -PercentComplete 10 -ParentId 1
|
||||||
$errMsg = ''
|
$errMsg = ''
|
||||||
if ($name.Length -eq 5) {
|
if ($name.Length -eq 5) {
|
||||||
$res = Get-AssetConversion $name
|
$res = Get-AssetConversion $name
|
||||||
if ($res) { return $res,'' }
|
if ($res) {
|
||||||
else { $errMsg += "$name Asset Tag not in SMBIOS`n" }
|
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
|
# We don't check CMDB asset tags here because they often resolve to
|
||||||
# something other than the hostname, like the asset tag itself
|
# 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
|
# 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}$") {
|
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
||||||
$res = Resolve-DnsName $name
|
$res = Resolve-DnsName $name
|
||||||
if ($res -and $res.NameHost -and ($res.NameHost -match "([^.]*)\.int\.samhealth\.net")) {
|
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],''
|
return $Matches[0],''
|
||||||
} else {
|
} else {
|
||||||
$errMsg += "$name IP Address couldn't be resolved to hostname`n"
|
$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) {
|
if ($name.Length -eq 7) {
|
||||||
$res = Get-ServiceTagConversion $name
|
$res = Get-ServiceTagConversion $name
|
||||||
if ($res) { return $res,'' }
|
if ($res) {
|
||||||
try {
|
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
|
||||||
$cmdbData = Search-ISMBO -bo cis -filter "SerialNumber eq '$name'" -RawFilter
|
return $res,''
|
||||||
} catch { $cmdbData = $null }
|
} else { $errMsg += "$name Service Tag not found in SCCM`n"}
|
||||||
if ( $cmdbData ) { return $cmdbData.Name, '' }
|
|
||||||
else { $errMsg += "$name Service Tag not found in SCCM nor CMDB`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
|
# 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})$") {
|
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
||||||
$res = Get-SCCM_PCFromMAC $name
|
$res = Get-SCCM_PCFromMAC $name
|
||||||
if ($res) { return $res,'' }
|
if ($res) {
|
||||||
else { $errMsg += "$name MAC Address not found in SCCM`n"}
|
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
|
# 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) {
|
if ($SCCMMatches -and $SCCMMatches.Count -lt 2) {
|
||||||
|
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
|
||||||
return $SCCMMatches,''
|
return $SCCMMatches,''
|
||||||
} elseif (!$SCCMMatches) { $errMsg += "No SCCM name match found`n" }
|
} elseif (!$SCCMMatches) { $errMsg += "No SCCM name match found`n" }
|
||||||
elseif ($SCCMMatches.Count -ge 2) { $errMsg += "Many SCCM name matches found`n" }
|
elseif ($SCCMMatches.Count -ge 2) { $errMsg += "Many SCCM name matches found`n" }
|
||||||
|
|
||||||
# CMDB check should be absolute last resort
|
# 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
|
$cmdbMatches = Find-ISMBO -bo cis -SearchQuery $name
|
||||||
if ($cmdbMatches -and $cmdbMatches.Count -lt 2) {
|
if ($cmdbMatches -and $cmdbMatches.Count -lt 2) {
|
||||||
|
Write-Progress -Activity "Resolving hostname for $name" -Completed -ParentId 1
|
||||||
return $cmdbMatches.Name,''
|
return $cmdbMatches.Name,''
|
||||||
} elseif (!$cmdbMatches) { $errMsg += "No CMDB name match found`n" }
|
} elseif (!$cmdbMatches) { $errMsg += "No CMDB name match found`n" }
|
||||||
elseif ($cmdbMatches.Count -ge 2) {
|
elseif ($cmdbMatches.Count -ge 2) {
|
||||||
# Try more specific queries
|
# Try more specific queries
|
||||||
# Asset tag
|
# Asset tag
|
||||||
|
Write-Progress -Activity "Resolving hostname for $name" -Status 'CMDB Asset Tag search' -PercentComplete 70 -ParentId 1
|
||||||
if ($name.Length -eq 5) {
|
if ($name.Length -eq 5) {
|
||||||
try {
|
try {
|
||||||
$cmdbData = Search-ISMBO -bo cis -Filter "AssetTag eq '$name'" -RawFilter
|
$cmdbData = Search-ISMBO -bo cis -Filter "AssetTag eq '$name'" -RawFilter
|
||||||
} catch { $cmdbData = $null }
|
} catch { $cmdbData = $null }
|
||||||
if ( $cmdbData ) {
|
if ( $cmdbData ) {
|
||||||
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
|
if (Resolve-DnsName $cmdbData.Name) {
|
||||||
else { $errMsg += "CMDB name associated with Asset tag $name doesn't resolve to IP Address"}
|
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" }
|
} 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})$") {
|
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
||||||
try {
|
try {
|
||||||
$cmdbData = Search-ISMBO -bo cis -Filter "MACAddress eq '$name'" -RawFilter
|
$cmdbData = Search-ISMBO -bo cis -Filter "MACAddress eq '$name'" -RawFilter
|
||||||
} catch { $cmdbData = $null }
|
} catch { $cmdbData = $null }
|
||||||
if ( $cmdbData ) {
|
if ( $cmdbData ) {
|
||||||
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
|
if (Resolve-DnsName $cmdbData.Name) {
|
||||||
else { $errMsg += "CMDB name associated with MAC Address $name doesn't resolve to IP Address"}
|
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" }
|
} else { $errMsg += "MAC Address not in CMDB" }
|
||||||
}
|
}
|
||||||
# Serial number
|
# Serial number
|
||||||
|
Write-Progress -Activity "Resolving hostname for $name" -Status 'CMDB Serial Number search' -PercentComplete 80 -ParentId 1
|
||||||
try {
|
try {
|
||||||
$cmdbData = Search-ISMBO -bo cis -Filter "SerialNumber eq '$name'" -RawFilter
|
$cmdbData = Search-ISMBO -bo cis -Filter "SerialNumber eq '$name'" -RawFilter
|
||||||
} catch { $cmdbData = $null }
|
} catch { $cmdbData = $null }
|
||||||
if ( $cmdbData ) {
|
if ( $cmdbData ) {
|
||||||
if (Resolve-DnsName $cmdbData.Name) { return $cmdbData.Name,'' }
|
if (Resolve-DnsName $cmdbData.Name) {
|
||||||
else { $errMsg += "CMDB name associated with Serial Number $name doesn't resolve to IP Address"}
|
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" }
|
} else { $errMsg += "Serial Number not in CMDB" }
|
||||||
$errMsg += "Many CMDB matches found`n"
|
$errMsg += "Many CMDB matches found`n"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
function Find-NextPrinterName($printerPrefix){
|
function Find-NextPrinterName($printerPrefix){
|
||||||
|
|
||||||
<#if($printerPrefix -eq $null){
|
if($printerPrefix -eq $null){
|
||||||
|
|
||||||
$printerPrefix = Read-Host "Printer Prefix"
|
$printerPrefix = Read-Host "Printer Prefix"
|
||||||
}
|
}
|
||||||
#>
|
|
||||||
$printerNames = @()
|
$printerNames = @()
|
||||||
$printerPrefix = Read-Host "Printer Prefix"
|
|
||||||
|
|
||||||
$printerNumber = 1
|
$printerNumber = 1
|
||||||
$printerName = ''
|
$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')
|
$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++){
|
for ($i=0; $i -lt 5; $i++){
|
||||||
#Write-Host $printerNumber
|
|
||||||
while($hit -eq $true){
|
while($hit -eq $true){
|
||||||
$hit = $false
|
$hit = $false
|
||||||
$printerName = "{0}{1:d2}" -f ($printerPrefix,$printerNumber)
|
$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){
|
foreach ($domain in $domains){
|
||||||
|
|
||||||
$printerHost = "$printerName$domain"
|
$printerHost = "$printerName$domain"
|
||||||
#Write-Host $printerHost
|
|
||||||
$testHost = Resolve-DnsName $printerHost
|
$testHost = Resolve-DnsName $printerHost
|
||||||
if($null -ne $testHost) {
|
if($null -ne $testHost) { $hit = $true }
|
||||||
$hit = $true
|
$di++
|
||||||
}
|
|
||||||
}
|
|
||||||
#Write-Host $printerHost
|
|
||||||
|
|
||||||
#Write-HOst $nslookup
|
|
||||||
if($hit -eq $true){
|
|
||||||
$printerNumber++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($hit -eq $true){ $printerNumber++ }
|
||||||
}
|
}
|
||||||
$printerNames += $printerName
|
$printerNames += $printerName
|
||||||
$printerNumber++
|
$printerNumber++
|
||||||
$hit = $true
|
$hit = $true
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Searching for next printer name" -Completed
|
||||||
#Write-Host "$printerName"
|
#Write-Host "$printerName"
|
||||||
return $printerNames
|
return $printerNames
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,20 @@
|
||||||
"Accept-Encoding" = "gzip, deflate, br"
|
"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_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_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
|
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 {$bitlocker = manage-bde -status C:} catch {$bitlocker = $null} # | Bitlocker Status
|
||||||
try {$PCInfo = get-computerinfo} catch {$PCInfo = $null}
|
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 {$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 ' || ' }
|
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
|
catch{ $win32_printer = $null} # | Printers
|
||||||
try {$imprivataRegEntry = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\SSOProvider\ISXAgent} catch {$imprivataRegEntry = $null}
|
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 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 {$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
|
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"
|
$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
|
#$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}
|
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
|
#Collecting most recent users from the registry
|
||||||
$lastuser = @()
|
$lastuser = @()
|
||||||
$profiles = Get-CimInstance -Class Win32_UserProfile
|
$profiles = Get-CimInstance -Class Win32_UserProfile
|
||||||
|
|
@ -130,7 +131,7 @@
|
||||||
|
|
||||||
#Drive Type
|
#Drive Type
|
||||||
$DriveType = $physicalDisk.MediaType
|
$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
|
#Free Harddrive Space
|
||||||
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
|
$CompFreeSpace = @([math]::Round($win32_LogicalDisk.FreeSpace / 1gb,2),[math]::Round($win32_LogicalDisk.Size / 1gb,2))
|
||||||
$free = $compFreeSpace[0]
|
$free = $compFreeSpace[0]
|
||||||
|
|
@ -182,7 +183,7 @@
|
||||||
}
|
}
|
||||||
$osBuild = $PCInfo.OSBuildNumber
|
$osBuild = $PCInfo.OSBuildNumber
|
||||||
$osBuild = "Vers $osVer | Build #$osBuild"
|
$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
|
||||||
$printers = $win32_printer# ($win32_printer | Where-Object {$_.PortName -ne 'PORTPROMPT:' -and $_.PortName -ne 'nul:' -and $_.PortName -ne 'SHRFAX:'} | Select-Object -ExpandProperty Name) -join ' || '
|
$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){
|
if(!$printers){
|
||||||
|
|
@ -238,7 +239,7 @@
|
||||||
$tpmStatus = "Off"
|
$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
|
#Citrix Version
|
||||||
if( !(Test-path $CitrixViewer)){
|
if( !(Test-path $CitrixViewer)){
|
||||||
|
|
||||||
|
|
@ -309,7 +310,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeout = 10
|
$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"
|
$uri = "$Tenant/api/odata/businessobject/cis`?`$filter=Name eq '$ENV:COMPUTERNAME'&`$top=1&`$skip=0"
|
||||||
try {
|
try {
|
||||||
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $Headers -TimeoutSec $timeout
|
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $Headers -TimeoutSec $timeout
|
||||||
|
|
@ -337,7 +338,7 @@
|
||||||
|
|
||||||
$LocationData = $LocationData -join ' | '
|
$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
|
#Output
|
||||||
# $i++ | ProgressBar $i $comp 'Generating Output' $NumberofComputers $PCID
|
# $i++ | ProgressBar $i $comp 'Generating Output' $NumberofComputers $PCID
|
||||||
$obj = New-Object -TypeName PSObject
|
$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 Vendor PC' -Value $cmdbData.SHS_IsVendorPC
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
|
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $cmdbData.SHS_ExceptionNotes
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Completed
|
||||||
|
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ function Invoke-PrinterPurge ($printer) {
|
||||||
|
|
||||||
for ($i = 0; $i -lt $comps.Length; $i += 1) {
|
for ($i = 0; $i -lt $comps.Length; $i += 1) {
|
||||||
$comp = $comps[$i]
|
$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 }
|
if ($comp -like "*EPIC*") { continue }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,16 @@ function get-resources {
|
||||||
param ( $pc )
|
param ( $pc )
|
||||||
|
|
||||||
$sBlock = {
|
$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
|
try {$win32_LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" } catch {$win32_LogicalDisk = $null} #| Diskspace
|
||||||
$obj = New-Object -TypeName PSObject
|
$obj = New-Object -TypeName PSObject
|
||||||
|
|
||||||
# Get system information
|
# 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
|
$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
|
$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
|
$sysMem = Get-WmiObject -Class Win32_PhysicalMemory
|
||||||
|
|
||||||
$sysOS = $sysInfo.Caption
|
$sysOS = $sysInfo.Caption
|
||||||
|
|
@ -23,12 +27,15 @@ function get-resources {
|
||||||
$sysTotalMem = $sysMem.Capacity / 1GB
|
$sysTotalMem = $sysMem.Capacity / 1GB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting resource data for $pc" -Status "Getting processor usage" -PercentComplete 66 -ParentId 1
|
||||||
# Get processor usage
|
# Get processor usage
|
||||||
$procUsage = [math]::Round((Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue)
|
$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
|
# Get memory usage
|
||||||
$memUsage = [Math]::Round((1 - (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue/($sysTotalMem*1GB/1MB))*100,1)
|
$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
|
# Get Physical Network Adapter information
|
||||||
$netAdapters = Get-NetAdapter -physical | Where-Object status -eq 'up'
|
$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 'freeDisk' -Value $freeDisk
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'maxDisk' -Value $maxDisk
|
$obj | Add-Member -MemberType NoteProperty -Name 'maxDisk' -Value $maxDisk
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting resource data for $pc" -Completed
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
$output = @()
|
$output = @()
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
|
|
||||||
Function Get-SCCMQuery {
|
Function Get-SCCMQuery {
|
||||||
param (
|
param (
|
||||||
[string]$comp,
|
[string]$comp
|
||||||
[int]$NumberofComputers,
|
|
||||||
[int]$PCID
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(!(Test-Connection -ComputerName $comp -Count 1)){
|
if(!(Test-Connection -ComputerName $comp -Count 1)){
|
||||||
|
|
@ -18,6 +16,7 @@ Function Get-SCCMQuery {
|
||||||
$compStatus = "Online"
|
$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'){
|
if(get-module -ListAvailable -Name 'ActiveDirectory'){
|
||||||
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
|
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
|
||||||
if($adTest){
|
if($adTest){
|
||||||
|
|
@ -26,7 +25,7 @@ Function Get-SCCMQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0
|
$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
|
$FindLastHardwareScanSCCM = Get-SCCMLastHardwareScan $comp
|
||||||
if(!$FindLastHardwareScanSCCM){
|
if(!$FindLastHardwareScanSCCM){
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
|
|
@ -54,38 +53,38 @@ Function Get-SCCMQuery {
|
||||||
|
|
||||||
return $obj
|
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
|
$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
|
$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
|
$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
|
$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
|
$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
|
$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
|
$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
|
$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
|
$i++; i++ | ProgressBar $i $comp "SCCM OS Name" $NumberofComputers $PCID
|
||||||
$FindOSNameSCCM = Get-SCCMFindOSNameQuery $comp
|
$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
|
$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
|
$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
|
$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
|
$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
|
$FindPCPrinterSCCM = Get-SCCMPCPrinter $comp
|
||||||
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for MAC address' -PercentComplete 85 -ParentId 1
|
||||||
$i++; i++ | ProgressBar $i $comp "SCCM MACAddress" $NumberofComputers $PCID
|
|
||||||
$FindMACAddressSCCM = Get-SCCMFindMACAddress $comp
|
$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)
|
$FindChassisTypeSCCM = Get-SCCMChassisType($comp)
|
||||||
if($FindAssetTagSCCM -is [array]){
|
if($FindAssetTagSCCM -is [array]){
|
||||||
Write-Warning "Dupe record in SCCM - $comp"
|
Write-Warning "Dupe record in SCCM - $comp"
|
||||||
|
|
@ -93,9 +92,8 @@ Function Get-SCCMQuery {
|
||||||
<#Get-CMDBFallback $comp#>
|
<#Get-CMDBFallback $comp#>
|
||||||
}
|
}
|
||||||
|
|
||||||
<#$cmdbData = Get-CMDBData $comp $FindAssetTagSCCM
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for CMDB data' -PercentComplete 95 -ParentId 1
|
||||||
$MDBLcmdblocation = Get-Cocation $cmdbData
|
$cmdbData = Search-ISMBO -bo cis -Filter "Name eq $comp" -RawFilter
|
||||||
#>
|
|
||||||
|
|
||||||
if($FindLastHardwareScanSCCM){
|
if($FindLastHardwareScanSCCM){
|
||||||
Write-Host "`n`nPulling cached SCCM data for $comp." -ForegroundColor Yellow
|
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
|
$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
|
$delInfo = Get-CMDBDELInfo $cmdbData
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Owner' -Value $delInfo.Owner
|
$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 Vendor PC' -Value $delInfo.Vendor
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
|
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
|
||||||
} #>
|
}
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,18 @@
|
||||||
|
|
||||||
function Get-SHSPrinter {
|
function Get-SHSPrinter {
|
||||||
param (
|
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
|
$snmp = New-Object -ComObject olePrn.OleSNMP
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($printer in $printers) {
|
|
||||||
|
|
||||||
#Gets the printer ip and full domain name
|
#Gets the printer ip and full domain name
|
||||||
$result = Get-PrinterIP $printer
|
$result = Get-PrinterIP $printer
|
||||||
|
|
||||||
#CMDB Data
|
#CMDB Data
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting printer details for $name" -Status 'Getting CMDB data' -PercentComplete 20 -ParentId 1
|
||||||
# $cmdbRecord = Get-LANDeskCMDBItem -Name $printer
|
# $cmdbRecord = Get-LANDeskCMDBItem -Name $printer
|
||||||
$cmdbRecord = Search-ISMBO -BO cis -filter "Name eq '$Printer'" -RawFilter
|
$cmdbRecord = Search-ISMBO -BO cis -filter "Name eq '$Printer'" -RawFilter
|
||||||
|
|
||||||
|
|
@ -36,11 +33,12 @@ function Get-SHSPrinter {
|
||||||
"SHS_LocationDetails"
|
"SHS_LocationDetails"
|
||||||
)
|
)
|
||||||
|
|
||||||
$LocationData = Foreach($Loc in $LocationConstructors){
|
$LocationData = Foreach ($Loc in $LocationConstructors) {
|
||||||
|
|
||||||
if ($Loc -eq 'SHS_Floor'){
|
if ($Loc -eq 'SHS_Floor') {
|
||||||
$(if ($cmdbRecord.$Loc -match '-'){$cmdbRecord.$Loc.split('-')[-1] + " Floor"} else{$cmdbRecord.$Loc})
|
$(if ($cmdbRecord.$Loc -match '-') { $cmdbRecord.$Loc.split('-')[-1] + " Floor" } else { $cmdbRecord.$Loc })
|
||||||
} elseif (![string]::IsNullOrEmpty($cmdbRecord.$Loc)){
|
}
|
||||||
|
elseif (![string]::IsNullOrEmpty($cmdbRecord.$Loc)) {
|
||||||
$cmdbRecord.$Loc
|
$cmdbRecord.$Loc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +52,7 @@ function Get-SHSPrinter {
|
||||||
# else{
|
# else{
|
||||||
# $locationData = $cmdbRecord.values._SHSCalcLocationString
|
# $locationData = $cmdbRecord.values._SHSCalcLocationString
|
||||||
# }
|
# }
|
||||||
if($cmdbRecord){
|
if ($cmdbRecord) {
|
||||||
# $CMDB_POA = $cmdbRecord.values._SHSPOANumber
|
# $CMDB_POA = $cmdbRecord.values._SHSPOANumber
|
||||||
# $CMDB_AssetTag = $cmdbRecord.values._SHSAssetTag
|
# $CMDB_AssetTag = $cmdbRecord.values._SHSAssetTag
|
||||||
# $CMDB_Location = $locationData
|
# $CMDB_Location = $locationData
|
||||||
|
|
@ -72,7 +70,7 @@ function Get-SHSPrinter {
|
||||||
$CMDB_serial = $cmdbRecord.SerialNumber
|
$CMDB_serial = $cmdbRecord.SerialNumber
|
||||||
$CMDB_IP = $cmdbRecord.IPAddress
|
$CMDB_IP = $cmdbRecord.IPAddress
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$CMDB_POA = "*CMDB Mismatch - check CMDB*"
|
$CMDB_POA = "*CMDB Mismatch - check CMDB*"
|
||||||
$CMDB_AssetTag = "*CMDB Mismatch - check CMDB*"
|
$CMDB_AssetTag = "*CMDB Mismatch - check CMDB*"
|
||||||
$CMDB_Location = "*CMDB Mismatch - check CMDB*"
|
$CMDB_Location = "*CMDB Mismatch - check CMDB*"
|
||||||
|
|
@ -82,8 +80,9 @@ function Get-SHSPrinter {
|
||||||
$CMDB_IP = "*CMDB Mismatch - check CMDB*"
|
$CMDB_IP = "*CMDB Mismatch - check CMDB*"
|
||||||
}
|
}
|
||||||
|
|
||||||
if($result.IP -ne $null) {
|
if ($result.IP -ne $null) {
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting printer details for $name" -Status 'Connecting to printer' -PercentComplete 30 -ParentId 1
|
||||||
|
|
||||||
$printerip = $result.IP
|
$printerip = $result.IP
|
||||||
$domainName = $result.Path
|
$domainName = $result.Path
|
||||||
|
|
@ -93,10 +92,11 @@ function Get-SHSPrinter {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($online){
|
if ($online) {
|
||||||
#opens snmp connection to the printer
|
#opens snmp connection to the printer
|
||||||
$snmp.open($printerip, 'public', 2, 3000)
|
$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
|
# Start of MAC
|
||||||
$pMAC = $SNMP.get(".1.3.6.1.2.1.2.2.1.6.2")
|
$pMAC = $SNMP.get(".1.3.6.1.2.1.2.2.1.6.2")
|
||||||
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
|
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
|
||||||
|
|
@ -105,26 +105,31 @@ function Get-SHSPrinter {
|
||||||
$MAC = $MAC -join ':'
|
$MAC = $MAC -join ':'
|
||||||
#End of MAC
|
#End of MAC
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for model' -PercentComplete 50 -ParentId 1
|
||||||
# MODEL
|
# MODEL
|
||||||
try { $model = $snmp.Get('.1.3.6.1.2.1.25.3.2.1.3.1') } catch { $model = $null }
|
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 IT HAS A MODEL NAME...
|
||||||
if ($model) {
|
if ($model) {
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting printer details for $name" -Status 'Querying for color' -PercentComplete 60 -ParentId 1
|
||||||
# COLOR
|
# COLOR
|
||||||
# might want to check on this one
|
# 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' }
|
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
|
# TRAYS
|
||||||
try { $trays = $($snmp.GetTree('.1.3.6.1.2.1.43.8.2.1.13') | ? {$_ -notlike 'print*'}) -join ';' } catch { $trays = $null }
|
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
|
# SERIAL
|
||||||
try { $serial = $snmp.Get('.1.3.6.1.2.1.43.5.1.1.17.1') } catch { $serial = $null }
|
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
|
#PAGECOUNT
|
||||||
|
|
||||||
try { $pagecount = $snmp.Get('.1.3.6.1.2.1.43.10.2.1.4.1.1') } catch { $page = $null }
|
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
|
##### FEATURES, NAME
|
||||||
switch -Regex ($model) {
|
switch -Regex ($model) {
|
||||||
'^sharp' {
|
'^sharp' {
|
||||||
|
|
@ -140,12 +145,17 @@ function Get-SHSPrinter {
|
||||||
#End of MAC
|
#End of MAC
|
||||||
}
|
}
|
||||||
'^zebra' {
|
'^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 }
|
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 }
|
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 }
|
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 { $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 }
|
# try { $status = $snmp.Get('.1.3.6.1.4.1.10642.200.4.1.0') } catch { $status = $null }
|
||||||
$model = "Zebra $model"
|
$model = "Zebra $model"
|
||||||
|
Write-Progress -Activity "Getting zebra features from $name" -Status 'Querying for status' -PercentComplete 90 -ParentId 2
|
||||||
#STATUS
|
#STATUS
|
||||||
$uri = $domainName
|
$uri = $domainName
|
||||||
$html = Invoke-WebRequest -uri $uri
|
$html = Invoke-WebRequest -uri $uri
|
||||||
|
|
@ -158,20 +168,28 @@ function Get-SHSPrinter {
|
||||||
$err = $split[1] -split '<'
|
$err = $split[1] -split '<'
|
||||||
$status = $status + ' ' + $err[0]
|
$status = $status + ' ' + $err[0]
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting zebra features from $name" -Completed
|
||||||
}
|
}
|
||||||
'^lexmark' {
|
'^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 }
|
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' {
|
'^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 }
|
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' {
|
'^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 }
|
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 }
|
try { $status = $snmp.Get('.1.3.6.1.4.1.11.2.3.9.1.1.3.0') } catch { $status = $null }
|
||||||
if($MAC -eq ''){
|
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')
|
$pMAC = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.1.12.1.2.5')
|
||||||
$MAC = ($pMAC -split " ")[-1]
|
$MAC = ($pMAC -split " ")[-1]
|
||||||
$MAC = ($MAC -replace '(..)','$1:').trim(':')
|
$MAC = ($MAC -replace '(..)', '$1:').trim(':')
|
||||||
|
|
||||||
}
|
}
|
||||||
#TONER
|
#TONER
|
||||||
|
|
@ -181,88 +199,99 @@ function Get-SHSPrinter {
|
||||||
HP Toner Cur: 1.3.6.1.2.1.43.11.1.1.9.1.1
|
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
|
HP Toner Max: 1.3.6.1.2.1.43.11.1.1.8.1.1
|
||||||
#>
|
#>
|
||||||
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 color' -PercentComplete 20 -ParentId 2
|
||||||
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.1')} catch {$tonerLvl = $null}
|
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.1') -split ' ')[0] } catch { $tonerColor = $null }
|
||||||
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.1')} catch {$tonerMax = $null}
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner level' -PercentComplete 25 -ParentId 2
|
||||||
try { $toner = $tonerLvl/$tonerMax} catch {$toner = $null}
|
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
|
[int]$toner = $toner * 100
|
||||||
$supplies = "$tonerColor"+":$toner% "
|
$supplies = "$tonerColor" + ":$toner% "
|
||||||
if($color -eq 'Yes'){
|
if ($color -eq 'Yes') {
|
||||||
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0]} catch { $tonerColor = $null}
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color levels' -PercentComplete 35 -ParentId 2
|
||||||
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2')} catch {$tonerLvl = $null}
|
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0] } catch { $tonerColor = $null }
|
||||||
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2')} catch {$tonerMax = $null}
|
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2') } catch { $tonerLvl = $null }
|
||||||
try { $toner = $tonerLvl/$tonerMax * 100} catch {$toner = $null}
|
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2') } catch { $tonerMax = $null }
|
||||||
$supplies += "$tonerColor"+":$toner% "
|
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
|
||||||
|
$supplies += "$tonerColor" + ":$toner% "
|
||||||
|
|
||||||
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.3') -split ' ')[0]} catch { $tonerColor = $null}
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color levels' -PercentComplete 50 -ParentId 2
|
||||||
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.3')} catch {$tonerLvl = $null}
|
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.3') -split ' ')[0] } catch { $tonerColor = $null }
|
||||||
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.3')} catch {$tonerMax = $null}
|
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.3') } catch { $tonerLvl = $null }
|
||||||
try { $toner = $tonerLvl/$tonerMax * 100} catch {$toner = $null}
|
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.3') } catch { $tonerMax = $null }
|
||||||
$supplies += "$tonerColor"+":$toner% "
|
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
|
||||||
|
$supplies += "$tonerColor" + ":$toner% "
|
||||||
|
|
||||||
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.4') -split ' ')[0]} catch { $tonerColor = $null}
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for toner color levels' -PercentComplete 65 -ParentId 2
|
||||||
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.4')} catch {$tonerLvl = $null}
|
try { $tonerColor = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.4') -split ' ')[0] } catch { $tonerColor = $null }
|
||||||
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.4')} catch {$tonerMax = $null}
|
try { $tonerLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.4') } catch { $tonerLvl = $null }
|
||||||
try { $toner = $tonerLvl/$tonerMax * 100} catch {$toner = $null}
|
try { $tonerMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.4') } catch { $tonerMax = $null }
|
||||||
$supplies += "$tonerColor"+":$toner% "
|
try { $toner = $tonerLvl / $tonerMax * 100 } catch { $toner = $null }
|
||||||
|
$supplies += "$tonerColor" + ":$toner% "
|
||||||
|
|
||||||
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6') -split ' ')[0]} catch { $tonerColor = $null}
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for maintenance kit status' -PercentComplete 80 -ParentId 2
|
||||||
if($supplyName -contains 'Fuser' -or $supplyName -contains 'Maint'){
|
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6') -split ' ')[0] } catch { $tonerColor = $null }
|
||||||
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.6')} catch { $supplyPartNumber = $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 }
|
||||||
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
|
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
|
||||||
$supplyPartNumber = $Matches.Name
|
$supplyPartNumber = $Matches.Name
|
||||||
try {$mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.6')} catch {$mainLvl = $null}
|
try { $mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.6') } catch { $mainLvl = $null }
|
||||||
try {$mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.6')} catch {$mainMax = $null}
|
try { $mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.6') } catch { $mainMax = $null }
|
||||||
if($mainMax -gt 1){
|
if ($mainMax -gt 1) {
|
||||||
try {$maintKit = $mainLvl / $mainMax} catch {$maintKit = $null}
|
try { $maintKit = $mainLvl / $mainMax } catch { $maintKit = $null }
|
||||||
[int]$maintKit = $maintKit * 100
|
[int]$maintKit = $maintKit * 100
|
||||||
|
|
||||||
if($null -ne $maintKit){
|
if ($null -ne $maintKit) {
|
||||||
$supplies += "| $supplyName" +":$maintKit%[$supplyPartNumber]"
|
$supplies += "| $supplyName" + ":$maintKit%[$supplyPartNumber]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.5') -split ' ')[1]} catch { $tonerColor = $null}
|
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.5') -split ' ')[1] } catch { $tonerColor = $null }
|
||||||
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.5')} catch { $supplyPartNumber = $null}
|
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.5') } catch { $supplyPartNumber = $null }
|
||||||
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
|
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
|
||||||
$supplyPartNumber = $Matches.Name
|
$supplyPartNumber = $Matches.Name
|
||||||
try {$mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.5')} catch {$mainLvl = $null}
|
try { $mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.5') } catch { $mainLvl = $null }
|
||||||
try {$mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.5')} catch {$mainMax = $null}
|
try { $mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.5') } catch { $mainMax = $null }
|
||||||
if($mainMax -gt 1){
|
if ($mainMax -gt 1) {
|
||||||
try {$maintKit = $mainLvl / $mainMax} catch {$maintKit = $null}
|
try { $maintKit = $mainLvl / $mainMax } catch { $maintKit = $null }
|
||||||
[int]$maintKit = $maintKit * 100
|
[int]$maintKit = $maintKit * 100
|
||||||
|
|
||||||
if($null -ne $maintKit){
|
if ($null -ne $maintKit) {
|
||||||
$supplies += "| $supplyName" +":$maintKit%[$supplyPartNumber]"
|
$supplies += "| $supplyName" + ":$maintKit%[$supplyPartNumber]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
try { $supplyName = ($snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2') -split ' ')[0]} catch { $supplyName = $null}
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for maintenance kit status' -PercentComplete 80 -ParentId 2
|
||||||
try { $supplyPartNumber = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.6.1.2')} catch { $supplyPartNumber = $null}
|
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
|
$supplyPartNumber -match '110V-(?<Name>.+), ' | Out-Null
|
||||||
$supplyPartNumber = $Matches.Name
|
$supplyPartNumber = $Matches.Name
|
||||||
try {$mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2')} catch {$mainLvl = $null}
|
try { $mainLvl = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.9.1.2') } catch { $mainLvl = $null }
|
||||||
try {$mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2')} catch {$mainMax = $null}
|
try { $mainMax = $snmp.Get('.1.3.6.1.2.1.43.11.1.1.8.1.2') } catch { $mainMax = $null }
|
||||||
if($mainMax -gt 1){
|
if ($mainMax -gt 1) {
|
||||||
try {$maintKit = $mainLvl / $mainMax} catch {$maintKit = $null}
|
try { $maintKit = $mainLvl / $mainMax } catch { $maintKit = $null }
|
||||||
[int]$maintKit = $maintKit * 100
|
[int]$maintKit = $maintKit * 100
|
||||||
|
|
||||||
if($null -ne $maintKit){
|
if ($null -ne $maintKit) {
|
||||||
$supplies += "| $supplyName" +":$maintKit%[$supplyPartNumber]"
|
$supplies += "| $supplyName" + ":$maintKit%[$supplyPartNumber]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting hp features from $name" -Completed
|
||||||
|
|
||||||
}
|
}
|
||||||
'^muratec' {
|
'^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 }
|
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 }
|
try { $status = $snmp.Get('.1.3.6.1.2.1.43.16.5.1.2.1.1') } catch { $status = $null }
|
||||||
# Start of MAC
|
# 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')
|
$pMAC = $SNMP.get('.1.3.6.1.4.1.4322.101.1.2.1.5.2.1.1.3.1')
|
||||||
Write-Host $pMAC
|
Write-Host $pMAC
|
||||||
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
|
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
|
||||||
|
|
@ -270,16 +299,17 @@ function Get-SHSPrinter {
|
||||||
}
|
}
|
||||||
$MAC = $MAC -join ':'
|
$MAC = $MAC -join ':'
|
||||||
#End of MAC
|
#End of MAC
|
||||||
|
Write-Progress -Activity "Getting muratec features from $name" -Completed
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}#end switch -Regex ($model)
|
||||||
#if ($model -like 'SHARP*') {}
|
#if ($model -like 'SHARP*') {}
|
||||||
|
|
||||||
|
}#end if ($model)
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
else{
|
|
||||||
$status = "Offline"
|
$status = "Offline"
|
||||||
$MAC = $CMDB_MAC
|
$MAC = $CMDB_MAC
|
||||||
$model = $CMDB_model
|
$model = $CMDB_model
|
||||||
|
|
@ -311,15 +341,13 @@ function Get-SHSPrinter {
|
||||||
}
|
}
|
||||||
$obj = New-Object -TypeName PSObject -Property $props
|
$obj = New-Object -TypeName PSObject -Property $props
|
||||||
$snmp.close()
|
$snmp.close()
|
||||||
|
Write-Progress -Activity "Getting printer details for $name" -Completed
|
||||||
return $obj
|
return $obj
|
||||||
|
}#end if ($printerIp)
|
||||||
|
if ($CMDB_IP) {
|
||||||
}
|
|
||||||
}
|
|
||||||
if($CMDB_IP){
|
|
||||||
$offlineIP = 'CMDB IP - ' + $CMDB_IP
|
$offlineIP = 'CMDB IP - ' + $CMDB_IP
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$offlineIP = 'No DNS Entry'
|
$offlineIP = 'No DNS Entry'
|
||||||
}
|
}
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
|
|
@ -342,7 +370,6 @@ function Get-SHSPrinter {
|
||||||
$snmp.close()
|
$snmp.close()
|
||||||
return $obj
|
return $obj
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
Write-Warning 'Active Drirectory Thick Client is required for this function'
|
Write-Warning 'Active Drirectory Thick Client is required for this function'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Getting user data for $name" -Status 'Querying AD for user data' -PercentComplete 30 -ParentId 1
|
||||||
if($user -match "^[\d\.]+$"){
|
if($user -match "^[\d\.]+$"){
|
||||||
$UserInfo = Get-ADUser -Filter { EmployeeID -eq $user } -properties *
|
$UserInfo = Get-ADUser -Filter { EmployeeID -eq $user } -properties *
|
||||||
$user = $UserInfo.SamAccountName
|
$user = $UserInfo.SamAccountName
|
||||||
|
|
@ -38,6 +39,8 @@
|
||||||
}
|
}
|
||||||
$manager = $UserInfo.Manager.Split("=,")[1]
|
$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
|
$computerSCCM = Get-SCCM_UserLastLoggedOn $user
|
||||||
$computerList = $computerSCCM -join ", "
|
$computerList = $computerSCCM -join ", "
|
||||||
$props = [ordered]@{
|
$props = [ordered]@{
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,19 @@ $getPCWrappedPath = '\\int.samhealth.net\files\TEAM\SHSISDesktopSolutions\Powers
|
||||||
Write-Host "`nGet-PC Module Version $Version [$devStage] Loaded." -ForegroundColor Green
|
Write-Host "`nGet-PC Module Version $Version [$devStage] Loaded." -ForegroundColor Green
|
||||||
if ($Version -ne $deployedVersion) {
|
if ($Version -ne $deployedVersion) {
|
||||||
Write-Host 'New version of Get-PC is available. Please run Get-PC -Update' -ForegroundColor Yellow
|
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
|
Write-Host "Enter 'Help Get-PC' for available commands.`n" -ForegroundColor Green
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -55,6 +68,7 @@ Function Get-PC {
|
||||||
-Monitor | monitors computers for changes in status
|
-Monitor | monitors computers for changes in status
|
||||||
-NextPrinterName | generates next open printer name
|
-NextPrinterName | generates next open printer name
|
||||||
-Orion | opens orion to the mac address of the pc
|
-Orion | opens orion to the mac address of the pc
|
||||||
|
-PatchNotes | read the patch notes
|
||||||
-PCCleanup | removes temp files and inactive user profiles
|
-PCCleanup | removes temp files and inactive user profiles
|
||||||
-PCReboot | reboots computer
|
-PCReboot | reboots computer
|
||||||
-PCRename | renames computer
|
-PCRename | renames computer
|
||||||
|
|
@ -181,13 +195,9 @@ Function Get-PC {
|
||||||
|
|
||||||
if($locationSearch){
|
if($locationSearch){
|
||||||
Write-Host 'Please enter a partial location like a room number.'
|
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 ..."
|
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){
|
if($searchInput.ToCharArray().Length -lt 3){
|
||||||
Write-Host 'Location searches much contain more than 2 characters' -ForegroundColor Yellow
|
Write-Host 'Location searches much contain more than 2 characters' -ForegroundColor Yellow
|
||||||
return
|
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()
|
$charA = $ComputerName.ToCharArray()
|
||||||
if($charA -contains '*'){
|
if($charA -contains '*'){
|
||||||
if($charA -lt 4){
|
if($charA -lt 4){
|
||||||
|
|
@ -231,10 +248,12 @@ Function Get-PC {
|
||||||
|
|
||||||
$getPCComputers = @() #List of computers that will get a batch query
|
$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
|
$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
|
$NumberofComputers = $ComputerName.Count
|
||||||
foreach ($comp in $ComputerName) {
|
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
|
#Pulls user data from AD
|
||||||
if ($SHSUser) {
|
if ($SHSUser) {
|
||||||
$user = Get-SHSUser $comp
|
$user = Get-SHSUser $comp
|
||||||
|
|
@ -243,6 +262,7 @@ Function Get-PC {
|
||||||
}
|
}
|
||||||
|
|
||||||
$comp,$msg = Get-Hostname $comp
|
$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) {
|
||||||
if ($SoundEnabled) {
|
if ($SoundEnabled) {
|
||||||
$oopsSoundPath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\gamblecore.wav'
|
$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
|
#Pulls basic SNMP Data from printer $comp
|
||||||
if ($SHSPrinter) {
|
if ($SHSPrinter) {
|
||||||
Write-Progress -Activity "Querying Printers" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete (($PCID / $NumberofComputers) * 100)
|
|
||||||
$printer = Get-SHSPrinter $comp
|
$printer = Get-SHSPrinter $comp
|
||||||
$outPutArray += $printer
|
$outPutArray += $printer
|
||||||
$PCID++
|
$PCID++
|
||||||
|
|
@ -306,6 +325,7 @@ Function Get-PC {
|
||||||
|
|
||||||
#Grabs all hostnames that have the requested printer installed on it
|
#Grabs all hostnames that have the requested printer installed on it
|
||||||
if ($HostnamesByPrinter) {
|
if ($HostnamesByPrinter) {
|
||||||
|
Write-Progress -Activity "Hostnames by printer for $comp" -Status "Querying SCCM" -PercentComplete 50 -Id 1
|
||||||
$printers = HostnamesByPrinter $comp
|
$printers = HostnamesByPrinter $comp
|
||||||
$out = @()
|
$out = @()
|
||||||
foreach ($printer in $printers) {
|
foreach ($printer in $printers) {
|
||||||
|
|
@ -320,6 +340,7 @@ Function Get-PC {
|
||||||
else {
|
else {
|
||||||
Write-Output $out
|
Write-Output $out
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Hostnames by printer for $comp" -Completed
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,12 +349,6 @@ Function Get-PC {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
#Generates an available printer hostname. Useful for supplying a new hostname in new printer requests
|
|
||||||
if ($NextPrinterName) {
|
|
||||||
Find-NextPrinterName $comp
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($Wake) {
|
if ($Wake) {
|
||||||
Invoke-Wake $comp
|
Invoke-Wake $comp
|
||||||
continue
|
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
|
#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
|
$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) {
|
if ($Connection) {
|
||||||
$compStatus = 'Online'
|
$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
|
#checks to see if the computer is in AD or the disabled computers OU and warns the user
|
||||||
if (get-module -ListAvailable -Name 'ActiveDirectory') {
|
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 }
|
try { $adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers") } catch { $adTest = $true }
|
||||||
|
|
||||||
if ($adTest) {
|
if ($adTest) {
|
||||||
|
|
@ -609,35 +625,23 @@ Function Get-PC {
|
||||||
(New-Object Media.SoundPlayer $oopsSoundPath).Play()
|
(New-Object Media.SoundPlayer $oopsSoundPath).Play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "Looking up computer in AD" -Completed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Direct SCCM Queries
|
#Direct SCCM Queries
|
||||||
if ( $SCCM ) {
|
if ( $SCCM ) {
|
||||||
$result = Get-SCCMQuery $comp $NumberofComputers $PCID
|
$result = Get-SCCMQuery $comp $NumberofComputers $PCID
|
||||||
$PCID++
|
|
||||||
$outPutArray += $result
|
$outPutArray += $result
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
|
||||||
#Checks if local computer
|
#Checks if local computer
|
||||||
if ($comp -eq $env:COMPUTERNAME) {
|
if ($comp -eq $env:COMPUTERNAME) {
|
||||||
|
|
||||||
$result = Get-PCLocal $comp $NumberofComputers $PCID
|
$result = Get-PCLocal $comp $NumberofComputers $PCID
|
||||||
#$PCID++
|
|
||||||
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
|
|
||||||
$outPutArray += $result
|
$outPutArray += $result
|
||||||
#$getPCComputers += $comp
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#$result = Get-PCRemote $comp $NumberofComputers $PCID
|
|
||||||
#$result = get-PCremoteCleaned $comp $Connection $NumberofComputers $PCID
|
|
||||||
#$PCID++
|
|
||||||
#$outPutArray += $result
|
|
||||||
#Write-Output $result
|
|
||||||
$getPCComputers += $comp
|
$getPCComputers += $comp
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Orion) {
|
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
|
# Monitor list of PCs for change in online status or
|
||||||
if ($Monitor) {
|
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)
|
|
||||||
}
|
|
||||||
|
|
@ -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 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
|
Patch: 2024-09-13
|
||||||
-Fix Order of hostame resolution changed so it's more consistent with true hostname
|
-Fix Order of hostame resolution changed so it's more consistent with true hostname
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue