Get-pc wrapped logging and various get-pc local bugs

This commit is contained in:
Zachary Gorman 2024-09-04 15:55:01 -07:00
parent e30dfa2aaa
commit 1da8a5dd3d
7 changed files with 61 additions and 35 deletions

View file

@ -12,7 +12,7 @@
RootModule = 'Get-PC.psm1' RootModule = 'Get-PC.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '0.4.4' ModuleVersion = '0.4.5'
# Supported PSEditions # Supported PSEditions
# CompatiblePSEditions = @() # CompatiblePSEditions = @()

View file

@ -37,7 +37,8 @@ function Get-Hostname ([string]$name) {
$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) {
return $cmdbMatches.Name,'' return $cmdbMatches.Name,''
} } elseif (!$cmdbMatches) { $errMsg += "No CMDB match found" }
elseif ($cmdbMatches.Count -ge 2) { $errMsg += "Many CMDB matches found" }
return $name, $errMsg return $name, $errMsg
} }

View file

@ -30,6 +30,8 @@
$i++ | ProgressBar $i $comp "Asset Tag" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Asset Tag" $NumberofComputers $PCID
$compAssetTag = Get-PCCompAssetTag $comp $compAssetTag = Get-PCCompAssetTag $comp
$i++ | ProgressBar $i $comp "Encryption" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Encryption" $NumberofComputers $PCID
$hasBitLocker = Get-PCHasBitLocker $comp
$i++ | ProgressBar $i $comp "OS Version" $NumberofComputers $PCID
$compOSVersion = Get-PCCompOSVersion $comp $compOSVersion = Get-PCCompOSVersion $comp
$i++ | ProgressBar $i $comp "OS Architecture" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "OS Architecture" $NumberofComputers $PCID
$compArchitectureBuild = Get-PCCompArchitectureBuild $comp $compArchitectureBuild = Get-PCCompArchitectureBuild $comp
@ -39,7 +41,7 @@
$driveType = Get-PCDriveType $comp $driveType = Get-PCDriveType $comp
$i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID
$citrixVersion = Get-PCCitrixVersion $comp $citrixVersion = Get-PCCitrixVersion $comp
$i++ | ProgressBar $i $comp "CPU Type" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Chassis Type" $NumberofComputers $PCID
$chassisType = Get-ChassisType $compCPU $compModel $chassisType = Get-ChassisType $compCPU $compModel
$i++ | ProgressBar $i $comp " Local Last User" $NumberofComputers $PCID $i++ | ProgressBar $i $comp " Local Last User" $NumberofComputers $PCID
@ -54,18 +56,13 @@
$releaseID = PCReleaseIDLocal $releaseID = PCReleaseIDLocal
$i++ | ProgressBar $i $comp "Local Printers" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Local Printers" $NumberofComputers $PCID
$getPrinter = Get-PCPrinterLocal $getPrinter = Get-PCPrinterLocal
$i++ | ProgressBar $i $comp "Time Stamp" $NumberofComputers $PCID #$i++ | ProgressBar $i $comp "Time Stamp" $NumberofComputers $PCID
#$lastUserTimeStamp = Get-PCLastUserTimestampLocal #$lastUserTimeStamp = Get-PCLastUserTimestampLocal
$i++ | ProgressBar $i $comp "GPO Status" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "GPO Status" $NumberofComputers $PCID
$getGPOStatus = Get-GPOStatusLocal $getGPOStatus = Get-GPOStatusLocal
$i++ | ProgressBar $i $comp "TPM Status" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "TPM Status" $NumberofComputers $PCID
$tpmStatus = Get-TPMStatusLocal $tpmStatus = Get-TPMStatusLocal
$i++ | ProgressBar $i $comp "Checking Bitlocker" $NumberofComputers $PCID
$hasBitLocker = Get-PCHasBitLockerLocal
$i++ | ProgressBar $i $comp "ChassisType" $NumberofComputers $PCID
$chassisType = Get-ChassisType $compCPU $compModel
if($lastUser.Count -gt 1){ if($lastUser.Count -gt 1){
$lastUser1 = ($lastUser[0].Name + "-(" + $lastUser[0].LastLoginTime + ")").Split("-") $lastUser1 = ($lastUser[0].Name + "-(" + $lastUser[0].LastLoginTime + ")").Split("-")
@ -125,14 +122,8 @@
$compFreeSpaceGB = "$compFreeSpaceGB" + ' GB' $compFreeSpaceGB = "$compFreeSpaceGB" + ' GB'
$compMemory = "$compMemory" + ' GB' $compMemory = "$compMemory" + ' GB'
if (Get-SparkEnabled) { $locationData = Get-LocationDetails $comp
$cmdbData = Get-SparkCI $ENV:ComputerName
$locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.SHS_LocationDetails
if($cmdbData.SHS_IsException -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
}
}
$i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID
$props = [Ordered]@{ $props = [Ordered]@{
@ -158,6 +149,7 @@
'TPM Status' = "$tpmStatus" 'TPM Status' = "$tpmStatus"
'MBAM GPO' = "$getGPOStatus" 'MBAM GPO' = "$getGPOStatus"
Printers = "$getPrinter" Printers = "$getPrinter"
'CMDB Location' = $locationData
} }
$obj = New-Object -TypeName PSObject -Property $props $obj = New-Object -TypeName PSObject -Property $props

View file

@ -18,6 +18,8 @@
$compModel = Get-PCCompModel $comp $compModel = Get-PCCompModel $comp
$i++ | ProgressBar $i $comp "RAM Size" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "RAM Size" $NumberofComputers $PCID
$compMemory = Get-PCCompMemory $comp $compMemory = Get-PCCompMemory $comp
$i++ | ProgressBar $i $comp "CPU Type" $NumberofComputers $PCID
$compCPU = Get-CPUType $comp
$i++ | ProgressBar $i $comp "HDD/SSD Space" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "HDD/SSD Space" $NumberofComputers $PCID
$compFreeSpace = Get-PCCompFreeSpace $comp $compFreeSpace = Get-PCCompFreeSpace $comp
$i++ | ProgressBar $i $comp "Service Tag" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Service Tag" $NumberofComputers $PCID
@ -40,8 +42,6 @@
$driveType = Get-PCDriveType $comp $driveType = Get-PCDriveType $comp
$i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID
$citrixVersion = Get-PCCitrixVersion $comp $citrixVersion = Get-PCCitrixVersion $comp
$i++ | ProgressBar $i $comp "CPU Type" $NumberofComputers $PCID
$compCPU = Get-CPUType $comp
$i++ | ProgressBar $i $comp "Chassis Type" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Chassis Type" $NumberofComputers $PCID
$chassisType = Get-ChassisType $compCPU $compModel $chassisType = Get-ChassisType $compCPU $compModel
@ -130,6 +130,8 @@
$compFreeSpaceMB = "$compFreeSpaceMB" + ' MB' $compFreeSpaceMB = "$compFreeSpaceMB" + ' MB'
$compFreeSpaceGB = "$compFreeSpaceGB" + ' GB' $compFreeSpaceGB = "$compFreeSpaceGB" + ' GB'
$compMemory = "$compMemory" + ' GB' $compMemory = "$compMemory" + ' GB'
$locationData = Get-LocationDetails $comp
$i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID
@ -156,6 +158,7 @@
'TPM Status' = "$tpmStatus" 'TPM Status' = "$tpmStatus"
'MBAM GPO' = "$getGPOStatus" 'MBAM GPO' = "$getGPOStatus"
Printers = "$getPrinter" Printers = "$getPrinter"
'CMDB Location' = $locationData
} }
$obj = New-Object -TypeName PSObject -Property $props $obj = New-Object -TypeName PSObject -Property $props
@ -557,4 +560,30 @@ Function Get-TimeOutJob ($Command){
$Job | Stop-Job $Job | Stop-Job
} }
}
Function Get-LocationDetails ($ComputerName) {
$cmdbRecord = Search-ISMBO -BO cis -filter "Name eq '$ComputerName'" -RawFilter
$LocationConstructors = @(
"SHS_AssetLocality",
"ivnt_Location",
"SHS_Floor",
"SHS_Department",
"SHS_LocationDetails"
)
$LocationData = Foreach($Loc in $LocationConstructors){
if ($Loc -eq 'SHS_Floor'){
$(if ($cmdbRecord.$Loc -match '-'){$cmdbRecord.$Loc.split('-')[-1] + " Floor"} else{$cmdbRecord.$Loc})
} elseif (![string]::IsNullOrEmpty($cmdbRecord.$Loc)){
$cmdbRecord.$Loc
}
}
$LocationData = $LocationData -join ' | '
return $LocationData
} }

View file

@ -54,36 +54,36 @@ Function Get-SCCMQuery {
return $obj return $obj
} }
$i++ | ProgressBar $i $comp "Last User SCCM" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "Last User SCCM" $NumberofComputers $PCID
$LastUserSCCM = Get-SCCMLastUserLogOnQuery $comp $LastUserSCCM = Get-SCCMLastUserLogOnQuery $comp
$i++ | ProgressBar $i $comp "SCCM IP Query" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM IP Query" $NumberofComputers $PCID
$FindIPSCCM = Get-SCCMIPQuery $comp $FindIPSCCM = Get-SCCMIPQuery $comp
$i++ | ProgressBar $i $comp "Find Model SCCM" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "Find Model SCCM" $NumberofComputers $PCID
$CompModelSCCM = Get-SCCMFindModelQuery $comp $CompModelSCCM = Get-SCCMFindModelQuery $comp
$i++ | ProgressBar $i $comp "SCCM Bios Version" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM Bios Version" $NumberofComputers $PCID
$FindBiosVerSCCM = Get-SCCMBiosVerQuery $comp $FindBiosVerSCCM = Get-SCCMBiosVerQuery $comp
$i++ | ProgressBar $i $comp "SCCM HDD/SSD Space" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM HDD/SSD Space" $NumberofComputers $PCID
$CompFreeSpaceSCCMGB = Get-SCCMFindFreeSpaceQuery $comp $CompFreeSpaceSCCMGB = Get-SCCMFindFreeSpaceQuery $comp
$i++ | ProgressBar $i $comp "SCCM RAM" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM RAM" $NumberofComputers $PCID
$FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp $FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp
$i++ | ProgressBar $i $comp "SCCM Asset Tag" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "SCCM Asset Tag" $NumberofComputers $PCID
$FindAssetTagSCCM = Get-SCCMFindAssetTagQuery $comp $FindAssetTagSCCM = Get-SCCMFindAssetTagQuery $comp
$i++ | ProgressBar $i $comp "SCCM Service Tag" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM Service Tag" $NumberofComputers $PCID
$FindServiceTagSCCM = Get-SCCMServiceTagQuery $comp $FindServiceTagSCCM = Get-SCCMServiceTagQuery $comp
$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++ | ProgressBar $i $comp "SCCM OS Architecture" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM OS Architecture" $NumberofComputers $PCID
$FindOSArchSCCM = Get-SCCMFindOSArch $comp $FindOSArchSCCM = Get-SCCMFindOSArch $comp
$i++ | ProgressBar $i $comp "SCCM OS Build" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM OS Build" $NumberofComputers $PCID
$FindOSBuild = Get-SCCMFindOSBuild $comp $FindOSBuild = Get-SCCMFindOSBuild $comp
$i++ | ProgressBar $i $comp "SCCM Encryption" $NumberofComputers $PCID $i++; i++ | ProgressBar $i $comp "SCCM Encryption" $NumberofComputers $PCID
$FindEncryptionSCCM = Get-SCCMFindEncryption $comp $FindEncryptionSCCM = Get-SCCMFindEncryption $comp
$i++ | ProgressBar $i $comp "SCCM Last Boot Up Time" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "SCCM Last Boot Up Time" $NumberofComputers $PCID
$FindLastBootUpTimeSCCM = Get-SCCMLastBootUpTime $comp $FindLastBootUpTimeSCCM = Get-SCCMLastBootUpTime $comp
$i++ | ProgressBar $i $comp "SCCM Printers" $NumberofComputers $PCID $i++ | ProgressBar $i $comp "SCCM Printers" $NumberofComputers $PCID
$FindPCPrinterSCCM = Get-SCCMPCPrinter $comp $FindPCPrinterSCCM = Get-SCCMPCPrinter $comp
$i++ | ProgressBar $i $comp "SCCM MACAddress" $NumberofComputers $PCID $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 $i++ | ProgressBar $i $comp "SCCM Chassis Type" $NumberofComputers $PCID
$FindChassisTypeSCCM = Get-SCCMChassisType($comp) $FindChassisTypeSCCM = Get-SCCMChassisType($comp)

View file

@ -4,7 +4,7 @@
#region Module Import Block #region Module Import Block
$ErrorActionPreference = 'SilentlyContinue' #$ErrorActionPreference = 'SilentlyContinue'
#DevStage can take either Dev or Prod as values #DevStage can take either Dev or Prod as values
$devStage = 'Dev' $devStage = 'Dev'
#Locations for dev build and prod build #Locations for dev build and prod build
@ -128,7 +128,6 @@ Function Get-PC {
[Switch]$WinProfileRebuild [Switch]$WinProfileRebuild
) )
<#
#Data collection for Get-PC Wrapped TM #Data collection for Get-PC Wrapped TM
$invokeData = @{ $invokeData = @{
Hostname = $env:COMPUTERNAME Hostname = $env:COMPUTERNAME
@ -137,7 +136,6 @@ Function Get-PC {
Parameters = $MyInvocation.BoundParameters Parameters = $MyInvocation.BoundParameters
} }
Add-Content -Path $getPCWrappedPath -Value $(ConvertTo-Json -Compress $invokeData) Add-Content -Path $getPCWrappedPath -Value $(ConvertTo-Json -Compress $invokeData)
#>
## Define which Spark Record Properties are Returned ## Define which Spark Record Properties are Returned
$Spark_Property_Return = @( $Spark_Property_Return = @(
@ -670,5 +668,5 @@ Function Get-PC {
} }
Function ProgressBar($Percent, $CurrentPC, $CurrentLocationText, $NumberofComputers, $CurrentPCNumber) { Function ProgressBar($Percent, $CurrentPC, $CurrentLocationText, $NumberofComputers, $CurrentPCNumber) {
Write-Progress -Activity "Scanning PC $CurrentPC ($CurrentPCNumber/$NumberofComputers)" -Status "Querying: $CurrentLocationText" -PercentComplete (($Percent / 18) * 100) Write-Progress -Activity "Scanning PC $CurrentPC ($CurrentPCNumber/$NumberofComputers)" -Status "Querying: $CurrentLocationText" -PercentComplete (($Percent / 29) * 100)
} }

View file

@ -1,3 +1,9 @@
Patch: 2024-09-04
-Add Logging for GetPCWrapped
-Fix Ambiguous CMDB results now report error message
-Add CMDB Location to get-pc local
-Fix Progress Bar bug with get-pc local
Patch: 2024-08-29 Patch: 2024-08-29
-Add CMDB flag to just query CMDB for fields -Add CMDB flag to just query CMDB for fields
-Fix bug in CMDB Fallback not reporting RAM correctly -Fix bug in CMDB Fallback not reporting RAM correctly