Too much, should've committed sooner lol
This commit is contained in:
parent
c41efaa728
commit
63bc3580e5
|
|
@ -5,6 +5,9 @@ function Get-PCBatchInvoke {
|
||||||
[string[]]
|
[string[]]
|
||||||
$Computers
|
$Computers
|
||||||
)
|
)
|
||||||
|
$Tenant = (Connect-ISM)[1]
|
||||||
|
$Headers = (Connect-ISM)[0]
|
||||||
|
|
||||||
$OnlineComputers = @()
|
$OnlineComputers = @()
|
||||||
$OfflineComputers = @()
|
$OfflineComputers = @()
|
||||||
$output = @()
|
$output = @()
|
||||||
|
|
@ -36,8 +39,10 @@ function Get-PCBatchInvoke {
|
||||||
$missedhosts = $OnlineComputers | Where-Object -FilterScript {$_ -notin $contactedhosts}
|
$missedhosts = $OnlineComputers | Where-Object -FilterScript {$_ -notin $contactedhosts}
|
||||||
$missedJobs = @()
|
$missedJobs = @()
|
||||||
if($missedhosts.count -gt 0){
|
if($missedhosts.count -gt 0){
|
||||||
|
$i = 1
|
||||||
foreach($computer in $missedhosts){
|
foreach($computer in $missedhosts){
|
||||||
$missedJobs += Start-Job -ScriptBlock ${function:Get-SCCMQueryBlock} -ArgumentList $computer
|
$missedJobs += Start-Job -ScriptBlock ${function:Get-SCCMQueryBlock} -ArgumentList $computer,$i
|
||||||
|
$i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output += $offlineJobs | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
$output += $offlineJobs | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
||||||
|
|
@ -63,11 +68,11 @@ function BatchInvokesProgressBar {
|
||||||
$stage
|
$stage
|
||||||
)
|
)
|
||||||
switch ($stage) {
|
switch ($stage) {
|
||||||
1 { Write-Progress -Activity "Connecting to computers" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
|
1 { Write-Progress -Activity "Connecting to computers" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100) -Id 0}
|
||||||
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((10/100) * 100)}
|
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((10/100) * 100) -Id 0}
|
||||||
3 { Write-Progress -Activity "Querying online computers" -PercentComplete ((20/100)*100)}
|
3 { Write-Progress -Activity "Querying online computers" -PercentComplete ((20/100)*100) -Id 0}
|
||||||
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) -Id 0}
|
||||||
5 { Write-Progress -Activity "Querying CMDB for computers not in SCCM" -PercentComplete ((85/100) * 100)}
|
5 { Write-Progress -Activity "Querying CMDB for computers not in SCCM" -PercentComplete ((85/100) * 100) -Id 0}
|
||||||
Default {}
|
Default {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ Function Find-ISMBusinessObject {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$Query = Invoke-RestMethod -Method GET -uri $URI -headers $Headers
|
$Query = Invoke-RestMethod -Method GET -uri $URI -headers $Headers -TimeoutSec $SparkQueryTimeoutSec
|
||||||
|
|
||||||
if (!$Query){
|
if (!$Query){
|
||||||
|
|
||||||
|
|
@ -177,7 +177,7 @@ Function Find-ISMBusinessObject {
|
||||||
|
|
||||||
$URI = "$Tenant/api/odata/businessobject/$BusinessObject`?`$top=100&`$skip=$Skip`$search=$SearchQuery"
|
$URI = "$Tenant/api/odata/businessobject/$BusinessObject`?`$top=100&`$skip=$Skip`$search=$SearchQuery"
|
||||||
|
|
||||||
$SkipQuery = Invoke-RestMethod -Method GET -uri $URI -headers $Headers
|
$SkipQuery = Invoke-RestMethod -Method GET -uri $URI -headers $Headers -TimeoutSec $SparkQueryTimeoutSec
|
||||||
|
|
||||||
if ($SkipQuery){
|
if ($SkipQuery){
|
||||||
$Results += $SkipQuery.Value
|
$Results += $SkipQuery.Value
|
||||||
|
|
|
||||||
|
|
@ -2,33 +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
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
Write-Progress -Activity "CMDB Fallback $comp" -Status 'Attempting to extract asset tag from name' -PercentComplete 40 -ParentId 1
|
||||||
if($comp.Length -gt 5){
|
if($comp.Length -ge 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
|
# 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]}
|
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.Name
|
||||||
Write-Progress -Activity "CMDB Fallback $name" -Status "Asset tag found, checking connection to $comp" -PercentComplete 70 -ParentId 1
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
Write-Progress -Activity "CMDB Fallback $comp" -Completed
|
||||||
return $getpcData
|
return $getpcData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Progress -Activity "CMDB Fallback $name" -Status 'Parsing Spark! results' -PercentComplete 60 -ParentId 1
|
Write-Progress -Activity "CMDB Fallback $comp" -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'
|
||||||
|
|
@ -63,7 +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
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
||||||
|
|
||||||
|
|
@ -125,11 +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
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
Write-Progress -Activity "CMDB Fallback $comp" -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
|
||||||
|
|
@ -138,7 +138,7 @@ function Get-CMDBFallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Hostname = "$comp"
|
Hostname = $cmdbData.Name
|
||||||
Status = $status
|
Status = $status
|
||||||
'Current User' = "Not Available"
|
'Current User' = "Not Available"
|
||||||
'Last User(s)' = $cmdbData.LoginName
|
'Last User(s)' = $cmdbData.LoginName
|
||||||
|
|
@ -174,7 +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
|
Write-Progress -Activity "CMDB Fallback $comp" -Completed
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
function Get-Hostname ([string]$name) {
|
function Get-Hostname ([string]$name) {
|
||||||
|
Write-Progress -Activity "Resolving hostname for $name" -PercentComplete 0 -ParentId 1
|
||||||
|
# Return early if the hostname already resolves
|
||||||
|
if (Resolve-DnsName $name) { return $name,''}
|
||||||
Write-Progress -Activity "Resolving hostname for $name" -Status 'SCCM Asset Tag Lookup' -PercentComplete 10 -ParentId 1
|
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) {
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ Function Get-ISMBusinessObject {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$Query = Invoke-RestMethod -Method GET -uri $URI -headers $Headers
|
$Query = Invoke-RestMethod -Method GET -uri $URI -headers $Headers -TimeoutSec $SparkQueryTimeoutSec
|
||||||
|
|
||||||
if (!$Query){
|
if (!$Query){
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ Function Get-ISMBusinessObject {
|
||||||
|
|
||||||
$URI = "$Tenant/api/odata/businessobject/$BusinessObject`?`$top=100&`$skip=$Skip"
|
$URI = "$Tenant/api/odata/businessobject/$BusinessObject`?`$top=100&`$skip=$Skip"
|
||||||
|
|
||||||
$SkipQuery = Invoke-RestMethod -Method GET -uri $URI -headers $Headers
|
$SkipQuery = Invoke-RestMethod -Method GET -uri $URI -headers $Headers -TimeoutSec $SparkQueryTimeoutSec
|
||||||
|
|
||||||
if ($SkipQuery){
|
if ($SkipQuery){
|
||||||
$Results += $SkipQuery.Value
|
$Results += $SkipQuery.Value
|
||||||
|
|
|
||||||
|
|
@ -309,13 +309,14 @@
|
||||||
Default {$chassisType = "Unknown Model/Chassis"}
|
Default {$chassisType = "Unknown Model/Chassis"}
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeout = 10
|
$timeout = if ($SparkQueryTimeoutSec) {$SparkQueryTimeoutSec} else {5}
|
||||||
Write-Progress -Activity "Retrieving data from $Env:COMPUTERNAME" -Status "Querying Spark! for location details. Timeout $($timeout)s" -PercentComplete 95
|
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
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host $_.Exception.Message
|
#Write-Host $_.Exception.Message
|
||||||
|
Write-Warning "Failed querying Spark!"
|
||||||
}
|
}
|
||||||
$cmdbData = $Query.Value
|
$cmdbData = $Query.Value
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ Function Get-SCCMQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0
|
|
||||||
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Last Hardware Scan' -PercentComplete 10 -ParentId 1
|
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){
|
||||||
|
|
@ -61,7 +60,7 @@ Function Get-SCCMQuery {
|
||||||
$CompModelSCCM = Get-SCCMFindModelQuery $comp
|
$CompModelSCCM = Get-SCCMFindModelQuery $comp
|
||||||
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Bios Version' -PercentComplete 30 -ParentId 1
|
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
|
||||||
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for storage space' -PercentComplete 35 -ParentId 1
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for HDD/SSD space' -PercentComplete 35 -ParentId 1
|
||||||
$CompFreeSpaceSCCMGB = Get-SCCMFindFreeSpaceQuery $comp
|
$CompFreeSpaceSCCMGB = Get-SCCMFindFreeSpaceQuery $comp
|
||||||
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for RAM' -PercentComplete 40 -ParentId 1
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for RAM' -PercentComplete 40 -ParentId 1
|
||||||
$FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp
|
$FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp
|
||||||
|
|
@ -70,7 +69,6 @@ Function Get-SCCMQuery {
|
||||||
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Service Tag' -PercentComplete 50 -ParentId 1
|
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
|
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
|
$FindOSNameSCCM = Get-SCCMFindOSNameQuery $comp
|
||||||
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for OS Architecture' -PercentComplete 60 -ParentId 1
|
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
|
||||||
|
|
@ -100,6 +98,7 @@ Function Get-SCCMQuery {
|
||||||
Write-Host "Last Hardware Scan Time: $FindLastHardwareScanSCCM" -ForegroundColor Yellow
|
Write-Host "Last Hardware Scan Time: $FindLastHardwareScanSCCM" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting SCCM data for $comp" -Completed
|
||||||
|
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Hostname = "$comp"
|
Hostname = "$comp"
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
Function Get-SCCMQueryBlock {
|
Function Get-SCCMQueryBlock {
|
||||||
param (
|
param (
|
||||||
[string]$comp,
|
[string]$comp,
|
||||||
[int]$NumberofComputers,
|
[int]$PCID = 1
|
||||||
[int]$PCID
|
|
||||||
)
|
)
|
||||||
#CONST
|
#CONST
|
||||||
$SITENAME="100"
|
$SITENAME="100"
|
||||||
|
|
@ -18,6 +17,8 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
$compStatus = "Online"
|
$compStatus = "Online"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$progress = 5
|
||||||
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Checking if disabled in AD' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
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){
|
||||||
|
|
@ -25,30 +26,14 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0
|
$progress += 5
|
||||||
$i++
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Last Hardware Scan' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Last Hardware Scan" -PercentComplete (($i / 18) * 100)
|
|
||||||
|
|
||||||
#Last Hardware Scan
|
#Last Hardware Scan
|
||||||
$FindLastHardwareScanQuery = "select SMS_G_System_WORKSTATION_STATUS.LastHardwareScan from SMS_R_System inner join SMS_G_System_WORKSTATION_STATUS on SMS_G_System_WORKSTATION_STATUS.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
$FindLastHardwareScanQuery = "select SMS_G_System_WORKSTATION_STATUS.LastHardwareScan from SMS_R_System inner join SMS_G_System_WORKSTATION_STATUS on SMS_G_System_WORKSTATION_STATUS.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
|
|
||||||
$FindLastHardwareScanSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindLastHardwareScanQuery | Select-Object -ExpandProperty LastHardwareScan
|
$FindLastHardwareScanSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindLastHardwareScanQuery | Select-Object -ExpandProperty LastHardwareScan
|
||||||
|
|
||||||
if($null -eq $FindLastHardwareScanSCCM){
|
|
||||||
return $null
|
|
||||||
}
|
|
||||||
|
|
||||||
$Year = $FindLastHardwareScanSCCM.substring(0,4)
|
|
||||||
$Month = $FindLastHardwareScanSCCM.substring(4,2)
|
|
||||||
$Day = $FindLastHardwareScanSCCM.substring(6,2)
|
|
||||||
|
|
||||||
$Hour = $FindLastHardwareScanSCCM.substring(8,2)
|
|
||||||
$Minute = $FindLastHardwareScanSCCM.substring(10,2)
|
|
||||||
$Second = $FindLastHardwareScanSCCM.substring(12,2)
|
|
||||||
|
|
||||||
$FindLastHardwareScanSCCM = "$Month/$Day/$Year $Hour" + ":" + "$Minute" + ":" + "$Second"
|
|
||||||
#End Last Hardware Scan
|
|
||||||
|
|
||||||
if(!$FindLastHardwareScanSCCM){
|
if(!$FindLastHardwareScanSCCM){
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Hostname = "$comp"
|
Hostname = "$comp"
|
||||||
|
|
@ -75,91 +60,95 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
|
|
||||||
return $obj
|
return $obj
|
||||||
}
|
}
|
||||||
$i++
|
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "Last User SCCM" -PercentComplete (($i / 18) * 100)
|
|
||||||
$SCCMLastUserLogOnQuery = "select SMS_R_System.LastLogonUserName from SMS_R_System where SMS_R_System.Name = '$comp'"
|
|
||||||
$LastUserSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $SCCMLastUserLogOnQuery |
|
|
||||||
Select-Object -ExpandProperty LastLogonUserName
|
|
||||||
|
|
||||||
$i++
|
$Year = $FindLastHardwareScanSCCM.substring(0,4)
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM IP Query" -PercentComplete (($i / 18) * 100)
|
$Month = $FindLastHardwareScanSCCM.substring(4,2)
|
||||||
$FindIPQuery = "select SMS_R_System.IPAddresses from SMS_R_System where SMS_R_System.Name = '$comp'"
|
$Day = $FindLastHardwareScanSCCM.substring(6,2)
|
||||||
$FindIPSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindIPQuery |
|
|
||||||
Select-Object -ExpandProperty IPAddresses
|
$Hour = $FindLastHardwareScanSCCM.substring(8,2)
|
||||||
|
$Minute = $FindLastHardwareScanSCCM.substring(10,2)
|
||||||
|
$Second = $FindLastHardwareScanSCCM.substring(12,2)
|
||||||
|
|
||||||
|
$FindLastHardwareScanSCCM = "$Month/$Day/$Year $Hour" + ":" + "$Minute" + ":" + "$Second"
|
||||||
|
#End Last Hardware Scan
|
||||||
|
|
||||||
|
$progress += 10
|
||||||
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Last User Logon' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
|
$SCCMQuery = "select SMS_R_System.LastLogonUserName,SMS_R_System.IPAddresses,SMS_R_System.MACAddresses from SMS_R_System where SMS_R_System.Name = '$comp'"
|
||||||
|
$SCCMResults = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $SCCMQuery
|
||||||
|
|
||||||
|
$LastUserSCCM = $SCCMResults | Select-Object -ExpandProperty LastLogonUserName
|
||||||
|
|
||||||
|
$FindIPSCCM = $SCCMResults | Select-Object -ExpandProperty IPAddresses
|
||||||
if($FindIPSCCM.Count -gt 1){
|
if($FindIPSCCM.Count -gt 1){
|
||||||
$FindIPSCCM = $FindIPSCCM[0]
|
$FindIPSCCM = $FindIPSCCM[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++
|
$FindMacAddressSCCM = $SCCMResults | Select-Object -ExpandProperty MACAddresses
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "Find Model SCCM" -PercentComplete (($i / 18) * 100)
|
$FindMacAddressSCCM = if($FindMacAddressSCCM.Count -gt 1){
|
||||||
|
$FindMacAddressSCCM[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
$progress += 10
|
||||||
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Model' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindModelQuery = "select SMS_G_System_COMPUTER_SYSTEM.Model from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on
|
$FindModelQuery = "select SMS_G_System_COMPUTER_SYSTEM.Model from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on
|
||||||
SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
$CompModelSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindModelQuery |
|
$CompModelSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindModelQuery |
|
||||||
Select-Object -ExpandProperty Model
|
Select-Object -ExpandProperty Model
|
||||||
|
|
||||||
$i++
|
$progress += 5
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Bios Version" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Bios Version' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindBiosVerQuery = "select SMS_G_System_PC_BIOS.SMBIOSBIOSVersion from SMS_R_System inner join SMS_G_System_PC_BIOS on
|
$FindBiosVerQuery = "select SMS_G_System_PC_BIOS.SMBIOSBIOSVersion from SMS_R_System inner join SMS_G_System_PC_BIOS on
|
||||||
SMS_G_System_PC_BIOS.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
SMS_G_System_PC_BIOS.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
$FindBiosVerSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindBiosVerQuery |
|
$FindBiosVerSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindBiosVerQuery |
|
||||||
Select-Object -ExpandProperty SMBIOSBIOSVersion
|
Select-Object -ExpandProperty SMBIOSBIOSVersion
|
||||||
|
|
||||||
$i++
|
$progress += 5
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM HDD/SSD Space" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for HDD/SSD space' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindFreeSpaceQuery = "select SMS_G_System_LOGICAL_DISK.Size from SMS_R_System inner join SMS_G_System_LOGICAL_DISK on
|
$FindFreeSpaceQuery = "select SMS_G_System_LOGICAL_DISK.Size from SMS_R_System inner join SMS_G_System_LOGICAL_DISK on
|
||||||
SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
$CompFreeSpaceSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindFreeSpaceQuery |
|
$CompFreeSpaceSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindFreeSpaceQuery |
|
||||||
Select-Object -ExpandProperty Size
|
Select-Object -ExpandProperty Size
|
||||||
$CompFreeSpaceSCCMGB = [math]::Round(($CompFreeSpaceSCCM / 1000), 2)
|
$CompFreeSpaceSCCMGB = [math]::Round(($CompFreeSpaceSCCM / 1000), 2)
|
||||||
|
|
||||||
$i++
|
$progress += 5
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM RAM" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for RAM' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindMemoryQuery = "select SMS_G_System_X86_PC_MEMORY.TotalPhysicalMemory from SMS_R_System inner join SMS_G_System_X86_PC_MEMORY on
|
$FindMemoryQuery = "select SMS_G_System_X86_PC_MEMORY.TotalPhysicalMemory from SMS_R_System inner join SMS_G_System_X86_PC_MEMORY on
|
||||||
SMS_G_System_X86_PC_MEMORY.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
SMS_G_System_X86_PC_MEMORY.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
$FindMemorySCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindMemoryQuery |
|
$FindMemorySCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindMemoryQuery |
|
||||||
Select-Object -ExpandProperty TotalPhysicalMemory
|
Select-Object -ExpandProperty TotalPhysicalMemory
|
||||||
$FindMemorySCCMGB = [math]::Round($FindMemorySCCM / 1MB)
|
$FindMemorySCCMGB = [math]::Round($FindMemorySCCM / 1MB)
|
||||||
|
|
||||||
$i++
|
$progress += 10
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Asset Tag" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Asset Tag' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindAssetTagQuery = "select SMS_G_System_SYSTEM_ENCLOSURE.SMBIOSAssetTag from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on
|
$SCCMQuery = "select SMS_G_System_SYSTEM_ENCLOSURE.SMBIOSAssetTag, SMS_G_System_SYSTEM_ENCLOSURE.SerialNumber from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on
|
||||||
SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$comp'"
|
SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$comp'"
|
||||||
$FindAssetTagSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindAssetTagQuery |
|
$SCCMResults = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $SCCMQuery
|
||||||
Select-Object -ExpandProperty SMBIOSAssetTag
|
$FindAssetTagSCCM = $SCCMResults | Select-Object -ExpandProperty SMBIOSAssetTag
|
||||||
|
$FindServiceTagSCCM = $SCCMResults | Select-Object -ExpandProperty SerialNumber
|
||||||
|
|
||||||
$i++
|
$progress += 10
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Service Tag" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for OS Name' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindServiceTagQuery = "select SMS_G_System_SYSTEM_ENCLOSURE.SerialNumber from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on
|
$SCCMQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber,SMS_G_System_OPERATING_SYSTEM.LastBootUpTime
|
||||||
SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM
|
||||||
$FindServiceTagSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindServiceTagQuery |
|
on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
Select-Object -ExpandProperty SerialNumber
|
$SCCMResults = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $SCCMQuery
|
||||||
|
$FindOSNameSCCM = $SCCMResults | Select-Object -ExpandProperty Caption
|
||||||
|
$FindOSArchSCCM = $SCCMResults | Select-Object -ExpandProperty OSArchitecture
|
||||||
|
$FindOSBuild = $SCCMResults | Select-Object -ExpandProperty BuildNumber
|
||||||
|
$FindLastBootUpTimeSCCM = $SCCMResults | Select-Object -ExpandProperty LastBootUpTime
|
||||||
|
if($null -ne $FindLastBootUpTimeSCCM){
|
||||||
|
$Year = $FindLastBootUpTimeSCCM.substring(0,4)
|
||||||
|
$Month = $FindLastBootUpTimeSCCM.substring(4,2)
|
||||||
|
$Day = $FindLastBootUpTimeSCCM.substring(6,2)
|
||||||
|
$Hour = $FindLastBootUpTimeSCCM.substring(8,2)
|
||||||
|
$Minute = $FindLastBootUpTimeSCCM.substring(10,2)
|
||||||
|
$Second = $FindLastBootUpTimeSCCM.substring(12,2)
|
||||||
|
$FindLastBootUpTimeSCCM = "$Month/$Day/$Year $Hour" + ":" + "$Minute" + ":" + "$Second"
|
||||||
|
}
|
||||||
|
|
||||||
$i++
|
$progress += 10
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM OS Name" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Encryption' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindOSNameQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber from
|
|
||||||
SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID =
|
|
||||||
SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
|
||||||
$FindOSNameSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindOSNameQuery |
|
|
||||||
Select-Object -ExpandProperty Caption
|
|
||||||
|
|
||||||
$i++
|
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM OS Architecture" -PercentComplete (($i / 18) * 100)
|
|
||||||
$FindOSNameQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber from
|
|
||||||
SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID =
|
|
||||||
SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
|
||||||
$FindOSArchSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindOSNameQuery |
|
|
||||||
Select-Object -ExpandProperty OSArchitecture
|
|
||||||
|
|
||||||
$i++
|
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM OS Build" -PercentComplete (($i / 18) * 100)
|
|
||||||
$FindOSNameQuery = "select SMS_G_System_OPERATING_SYSTEM.Caption, SMS_G_System_OPERATING_SYSTEM.OSArchitecture, SMS_G_System_OPERATING_SYSTEM.BuildNumber from
|
|
||||||
SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID =
|
|
||||||
SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
|
||||||
$FindOSBuild = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindOSNameQuery |
|
|
||||||
Select-Object -ExpandProperty BuildNumber
|
|
||||||
|
|
||||||
$i++
|
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Encryption" -PercentComplete (($i / 18) * 100)
|
|
||||||
$FindEncryptionQuery = "select SMS_G_System_ENCRYPTABLE_VOLUME.ProtectionStatus from SMS_R_System inner join SMS_G_System_ENCRYPTABLE_VOLUME on
|
$FindEncryptionQuery = "select SMS_G_System_ENCRYPTABLE_VOLUME.ProtectionStatus from SMS_R_System inner join SMS_G_System_ENCRYPTABLE_VOLUME on
|
||||||
SMS_G_System_ENCRYPTABLE_VOLUME.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
SMS_G_System_ENCRYPTABLE_VOLUME.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
$FindEncryptionSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindEncryptionQuery |
|
$FindEncryptionSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindEncryptionQuery |
|
||||||
|
|
@ -171,25 +160,8 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
Default{$FindEncryptionSCCM = "Encryption Not Found"}
|
Default{$FindEncryptionSCCM = "Encryption Not Found"}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++
|
$progress += 5
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Last Boot Up Time" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Printers' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindLastBootUpTimeQuery = "select SMS_G_System_OPERATING_SYSTEM.LastBootUpTime from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on
|
|
||||||
SMS_G_System_OPERATING_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
|
||||||
|
|
||||||
$FindLastBootUpTimeSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindLastBootUpTimeQuery |
|
|
||||||
Select-Object -ExpandProperty LastBootUpTime
|
|
||||||
if($null -ne $FindLastBootUpTimeSCCM){
|
|
||||||
$Year = $FindLastBootUpTimeSCCM.substring(0,4)
|
|
||||||
$Month = $FindLastBootUpTimeSCCM.substring(4,2)
|
|
||||||
$Day = $FindLastBootUpTimeSCCM.substring(6,2)
|
|
||||||
$Hour = $FindLastBootUpTimeSCCM.substring(8,2)
|
|
||||||
$Minute = $FindLastBootUpTimeSCCM.substring(10,2)
|
|
||||||
$Second = $FindLastBootUpTimeSCCM.substring(12,2)
|
|
||||||
$FindLastBootUpTimeSCCM = "$Month/$Day/$Year $Hour" + ":" + "$Minute" + ":" + "$Second"
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++
|
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Printers" -PercentComplete (($i / 18) * 100)
|
|
||||||
$FindPCPrinterQuery = "select SMS_G_System_PRINTER_DEVICE.Name, SMS_G_System_PRINTER_DEVICE.PortName from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE
|
$FindPCPrinterQuery = "select SMS_G_System_PRINTER_DEVICE.Name, SMS_G_System_PRINTER_DEVICE.PortName from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE
|
||||||
on SMS_G_System_PRINTER_DEVICE.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
on SMS_G_System_PRINTER_DEVICE.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Name = '$comp'"
|
||||||
$FindPCPrinterSCCM = (Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindPCPrinterQuery |
|
$FindPCPrinterSCCM = (Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindPCPrinterQuery |
|
||||||
|
|
@ -197,16 +169,8 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
Where-Object -Property PortName -ne PORTPROMPT: |
|
Where-Object -Property PortName -ne PORTPROMPT: |
|
||||||
Where-Object -Property PortName -ne SHRFAX: | Select-Object -ExpandProperty Name) -join ' || '
|
Where-Object -Property PortName -ne SHRFAX: | Select-Object -ExpandProperty Name) -join ' || '
|
||||||
|
|
||||||
$i++
|
$progress += 10
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM MACAddress" -PercentComplete (($i / 18) * 100)
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for Chassis Type' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
$FindMacAddressQuery = "select SMS_R_System.MACAddresses from SMS_R_System where SMS_R_System.Name = '$comp'"
|
|
||||||
$FindMacAddressSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindMacAddressQuery | Select-Object -ExpandProperty MACAddresses
|
|
||||||
$FindMacAddressSCCM = if($FindMacAddressSCCM.Count -gt 1){
|
|
||||||
$FindMacAddressSCCM[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++
|
|
||||||
Write-Progress -Activity "Scanning PC $comp" -Status "SCCM Chassis Type" -PercentComplete (($i / 18) * 100)
|
|
||||||
$FindProcessorQuery = "select SMS_G_System_PROCESSOR.Name from SMS_R_System inner join SMS_G_System_PROCESSOR on SMS_G_System_PROCESSOR.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on
|
$FindProcessorQuery = "select SMS_G_System_PROCESSOR.Name from SMS_R_System inner join SMS_G_System_PROCESSOR on SMS_G_System_PROCESSOR.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on
|
||||||
SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$comp'"
|
SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$comp'"
|
||||||
$FindProcessorSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindProcessorQuery | Select-Object -ExpandProperty Name
|
$FindProcessorSCCM = Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $FindProcessorQuery | Select-Object -ExpandProperty Name
|
||||||
|
|
@ -266,16 +230,16 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
$MDBLcmdblocation = Get-Cocation $cmdbData
|
$MDBLcmdblocation = Get-Cocation $cmdbData
|
||||||
#>
|
#>
|
||||||
|
|
||||||
if($FindLastHardwareScanSCCM){
|
$progress += 5
|
||||||
Write-Host "`n`nPulling cached SCCM data for $comp." -ForegroundColor Yellow
|
Write-Progress -Activity "Getting SCCM data for $comp" -Status 'Querying for CMDB data' -PercentComplete $progress -ParentID 0 -Id $PCID
|
||||||
Write-Host "Last Hardware Scan Time: $FindLastHardwareScanSCCM" -ForegroundColor Yellow
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$timeout = if ($SparkQueryTimeoutSec) {$SparkQueryTimeoutSec} else {5}
|
||||||
$uri = "${using:Tenant}/api/odata/businessobject/cis`?`$filter=Name eq '$comp'&`$top=1&`$skip=0"
|
$uri = "${using:Tenant}/api/odata/businessobject/cis`?`$filter=Name eq '$comp'&`$top=1&`$skip=0"
|
||||||
try {
|
try {
|
||||||
$Query = Invoke-RestMethod -Method GET -uri $uri -headers ${using:Headers}
|
$Query = Invoke-RestMethod -Method GET -uri $uri -headers ${using:Headers} -TimeoutSec $timeout
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host $_.Exception.Message
|
#Write-Host $_.Exception.Message
|
||||||
|
Write-Warning "Failed querying Spark!"
|
||||||
}
|
}
|
||||||
$cmdbData = $Query.Value
|
$cmdbData = $Query.Value
|
||||||
|
|
||||||
|
|
@ -287,16 +251,23 @@ $SCCMNAMESPACE="root\sms\site_100"
|
||||||
"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 ($cmdbData.$Loc -match '-'){$cmdbData.$Loc.split('-')[-1] + " Floor"} else{$cmdbData.$Loc})
|
$(if ($cmdbData.$Loc -match '-'){$cmdbData.$Loc.split('-')[-1] + " Floor"} else{$cmdbData.$Loc})
|
||||||
} elseif (![string]::IsNullOrEmpty($cmdbData.$Loc)){
|
} elseif (![string]::IsNullOrEmpty($cmdbData.$Loc)){
|
||||||
$cmdbData.$Loc
|
$cmdbData.$Loc
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$LocationData = $LocationData -join ' | '
|
$LocationData = $LocationData -join ' | '
|
||||||
|
|
||||||
|
if($FindLastHardwareScanSCCM){
|
||||||
|
Write-Host "`n`nPulling cached SCCM data for $comp." -ForegroundColor Yellow
|
||||||
|
Write-Host "Last Hardware Scan Time: $FindLastHardwareScanSCCM" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Progress -Activity "Getting SCCM data for $comp" -Completed
|
||||||
|
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Hostname = "$comp"
|
Hostname = "$comp"
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,6 @@ function Get-SHSPrinter {
|
||||||
try { $status = $snmp.Get('.1.3.6.1.2.1.43.18.1.1.8.1.1') } catch { $status = $null }
|
try { $status = $snmp.Get('.1.3.6.1.2.1.43.18.1.1.8.1.1') } catch { $status = $null }
|
||||||
# Start of MAC
|
# Start of MAC
|
||||||
$pMAC = $SNMP.get(".1.3.6.1.4.1.11.2.4.3.1.23.0")
|
$pMAC = $SNMP.get(".1.3.6.1.4.1.11.2.4.3.1.23.0")
|
||||||
write-host $pMAC.ToString()
|
|
||||||
|
|
||||||
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
|
$MAC = [System.Text.Encoding]::Default.GetBytes($PMac) | ForEach-Object {
|
||||||
$_.ToString('X2')
|
$_.ToString('X2')
|
||||||
|
|
@ -185,6 +184,20 @@ function Get-SHSPrinter {
|
||||||
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
|
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 }
|
||||||
|
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for IP configuration' -PercentComplete 10 -ParentId 2
|
||||||
|
try { $ipconfig = $snmp.Get('.1.3.6.1.4.1.11.2.4.3.5.1.0') } catch { $status = $null }
|
||||||
|
$ipconfig = switch ($ipconfig) {
|
||||||
|
1 { '(manual)' } #manual-one
|
||||||
|
2 { '(bootp)' } #bootp-two
|
||||||
|
3 { '(manual)' } #manual-three
|
||||||
|
4 { '(bootp)' } #bootp-four
|
||||||
|
5 { '(dhcp)' } #dhcp
|
||||||
|
6 { '' } #not-configured
|
||||||
|
7 { '(default)' } #default-config
|
||||||
|
8 { '(rarp)' } #rarp
|
||||||
|
9 { '' } #read-only
|
||||||
|
10 { '(auto-ip)' } #auto-ip
|
||||||
|
}
|
||||||
if ($MAC -eq '') {
|
if ($MAC -eq '') {
|
||||||
Write-Progress -Activity "Getting hp features from $name" -Status 'Querying for MAC Address' -PercentComplete 15 -ParentId 2
|
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')
|
||||||
|
|
@ -322,7 +335,7 @@ function Get-SHSPrinter {
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Machine = $printer
|
Machine = $printer
|
||||||
Status = $status
|
Status = $status
|
||||||
IP = $printerip
|
IP = "$printerip $ipconfig"
|
||||||
DomainName = $domainName
|
DomainName = $domainName
|
||||||
MAC = $MAC
|
MAC = $MAC
|
||||||
Model = $model
|
Model = $model
|
||||||
|
|
|
||||||
46
Private/ScanToEmail.ps1
Normal file
46
Private/ScanToEmail.ps1
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
function ScanToEmail {
|
||||||
|
param (
|
||||||
|
[string]$printer
|
||||||
|
)
|
||||||
|
|
||||||
|
$DNSServers = @{
|
||||||
|
'Sam Square/Walnut' = @{
|
||||||
|
'Primary' = '10.98.2.45'
|
||||||
|
'Secondary' = '10.98.2.74'
|
||||||
|
}
|
||||||
|
'AGH' = @{
|
||||||
|
'Primary' = '10.10.15.11'
|
||||||
|
'Secondary' = '10.30.15.18'
|
||||||
|
}
|
||||||
|
'SPCH' = @{
|
||||||
|
'Primary' = '10.50.15.25'
|
||||||
|
'Secondary' = '10.60.15.14'
|
||||||
|
}
|
||||||
|
'GSRMC' = @{
|
||||||
|
'Primary' = '10.20.15.16'
|
||||||
|
'Secondary' = '10.98.2.74'
|
||||||
|
}
|
||||||
|
'SLCH' = @{
|
||||||
|
'Primary' = '10.30.15.18'
|
||||||
|
'Secondary' = '10.10.15.11'
|
||||||
|
}
|
||||||
|
'SNLH' = @{
|
||||||
|
'Primary' = '10.60.15.14'
|
||||||
|
'Secondary' = '10.50.15.25'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
Typically SNMP is set to read-only on most printers so we'll have to
|
||||||
|
replicate web requests. There isn't really a standard so this support
|
||||||
|
will have to be added for each new scheme. We can determine which scheme
|
||||||
|
to use based on the model number
|
||||||
|
#>
|
||||||
|
$snmp = New-Object -ComObject olePrn.OleSNMP
|
||||||
|
$printerip = (Resolve-DnsName $printer).IPAddress
|
||||||
|
$snmp.open($printerip, 'public', 2, 3000)
|
||||||
|
try { $model = $snmp.Get('.1.3.6.1.2.1.25.3.2.1.3.1') } catch { $model = $null }
|
||||||
|
switch -Regex ($model) {
|
||||||
|
'^HP LaserJet Pro M404n' { $function:ScanToEmailHPLJM400}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -298,7 +298,7 @@ BEGIN {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$Query = $null
|
$Query = $null
|
||||||
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $headers
|
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $headers -TimeoutSec $SparkQueryTimeoutSec
|
||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -322,7 +322,7 @@ BEGIN {
|
||||||
|
|
||||||
$uri = "$Tenant/api/odata/businessobject/$BusinessObject`?`$filter=$($FilterEncodes[$FilterEncode])&`$top=100&`$skip=$Skip"
|
$uri = "$Tenant/api/odata/businessobject/$BusinessObject`?`$filter=$($FilterEncodes[$FilterEncode])&`$top=100&`$skip=$Skip"
|
||||||
|
|
||||||
$SkipQuery = Invoke-RestMethod -Method GET -uri $uri -headers $headers
|
$SkipQuery = Invoke-RestMethod -Method GET -uri $uri -headers $headers -TimeoutSec $SparkQueryTimeoutSec
|
||||||
|
|
||||||
if ($SkipQuery){
|
if ($SkipQuery){
|
||||||
$Results += $SkipQuery.Value
|
$Results += $SkipQuery.Value
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ elseif ($devStage -eq "Dev") {
|
||||||
|
|
||||||
$getPCWrappedPath = '\\int.samhealth.net\files\TEAM\SHSISDesktopSolutions\Powershell\Get-PC_Update_2023\Get-PC-Wrapped\backlog.txt'
|
$getPCWrappedPath = '\\int.samhealth.net\files\TEAM\SHSISDesktopSolutions\Powershell\Get-PC_Update_2023\Get-PC-Wrapped\backlog.txt'
|
||||||
|
|
||||||
|
$SparkQueryTimeoutSec = 5
|
||||||
|
|
||||||
#lets user know when get-pc has been imported and what version they are running
|
#lets user know when get-pc has been imported and what version they are running
|
||||||
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) {
|
||||||
|
|
@ -269,11 +271,11 @@ Function Get-PC {
|
||||||
(New-Object Media.SoundPlayer $oopsSoundPath).Play()
|
(New-Object Media.SoundPlayer $oopsSoundPath).Play()
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "`n$msg" -ForegroundColor Red
|
Write-Host "`n$comp`n$msg" -ForegroundColor Red
|
||||||
|
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Hostname = "$msg"
|
Hostname = "$comp"
|
||||||
Status = ""
|
Status = "$msg"
|
||||||
'Current User' = ""
|
'Current User' = ""
|
||||||
'Last User(s)' = ""
|
'Last User(s)' = ""
|
||||||
'IP | MAC' = ""
|
'IP | MAC' = ""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,16 @@
|
||||||
Hi, I'm the patch notes, nice to meet you!
|
Hi, I'm the patch notes, nice to meet you! You can find me with the -PatchNotes flag.
|
||||||
These are the changes in the most recent update of Get-PC
|
These are the changes in the most recent update of Get-PC
|
||||||
|
Patch: 2024-09-23
|
||||||
|
-Add SHSPrinter IP indicates config method (dhcp, manual, etc.)
|
||||||
|
-Fix hostname search ends early if user supplied a correct hostname to get-pc (prevents recently changed hostname from failing)
|
||||||
|
-Fix Spark timeouts applied everywhere
|
||||||
|
-Fix bug where SCCM scan from BatchInvokes returns without making an object
|
||||||
|
-Fix found more Spark! error messages to suppress
|
||||||
|
-Fix SCCM queries have better progress bars
|
||||||
|
-Fix CMDB fallback reporting that it's querying an empty hostname but queries other details successfully
|
||||||
|
-Fix combined some SCCM queries for speed in BatchInvokes
|
||||||
|
-Tip try setting $SoundEnabled = $true then query a pc that's off domain
|
||||||
|
|
||||||
Patch: 2024-09-18
|
Patch: 2024-09-18
|
||||||
-Add When update is announced, most recent patch notes are announced with it
|
-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
|
-Add Patchnotes flag to the help readout so users know what's new
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue