diff --git a/Get-PC.psd1 b/Get-PC.psd1 index 33941f4..11f8178 100644 --- a/Get-PC.psd1 +++ b/Get-PC.psd1 @@ -12,7 +12,7 @@ RootModule = 'Get-PC.psm1' # Version number of this module. -ModuleVersion = '0.4.4' +ModuleVersion = '0.4.5' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/Private/Get-Hostname.ps1 b/Private/Get-Hostname.ps1 index 264bb78..a0bc18c 100644 --- a/Private/Get-Hostname.ps1 +++ b/Private/Get-Hostname.ps1 @@ -37,7 +37,8 @@ function Get-Hostname ([string]$name) { $cmdbMatches = Find-ISMBO -bo cis -SearchQuery $name if ($cmdbMatches -and $cmdbMatches.Count -lt 2) { return $cmdbMatches.Name,'' - } + } elseif (!$cmdbMatches) { $errMsg += "No CMDB match found" } + elseif ($cmdbMatches.Count -ge 2) { $errMsg += "Many CMDB matches found" } return $name, $errMsg } \ No newline at end of file diff --git a/Private/PCLocal.ps1 b/Private/PCLocal.ps1 index 68295a7..70fed16 100644 --- a/Private/PCLocal.ps1 +++ b/Private/PCLocal.ps1 @@ -30,6 +30,8 @@ $i++ | ProgressBar $i $comp "Asset Tag" $NumberofComputers $PCID $compAssetTag = Get-PCCompAssetTag $comp $i++ | ProgressBar $i $comp "Encryption" $NumberofComputers $PCID + $hasBitLocker = Get-PCHasBitLocker $comp + $i++ | ProgressBar $i $comp "OS Version" $NumberofComputers $PCID $compOSVersion = Get-PCCompOSVersion $comp $i++ | ProgressBar $i $comp "OS Architecture" $NumberofComputers $PCID $compArchitectureBuild = Get-PCCompArchitectureBuild $comp @@ -39,7 +41,7 @@ $driveType = Get-PCDriveType $comp $i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID $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 $i++ | ProgressBar $i $comp " Local Last User" $NumberofComputers $PCID @@ -54,18 +56,13 @@ $releaseID = PCReleaseIDLocal $i++ | ProgressBar $i $comp "Local Printers" $NumberofComputers $PCID $getPrinter = Get-PCPrinterLocal - $i++ | ProgressBar $i $comp "Time Stamp" $NumberofComputers $PCID + #$i++ | ProgressBar $i $comp "Time Stamp" $NumberofComputers $PCID #$lastUserTimeStamp = Get-PCLastUserTimestampLocal $i++ | ProgressBar $i $comp "GPO Status" $NumberofComputers $PCID $getGPOStatus = Get-GPOStatusLocal $i++ | ProgressBar $i $comp "TPM Status" $NumberofComputers $PCID $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){ $lastUser1 = ($lastUser[0].Name + "-(" + $lastUser[0].LastLoginTime + ")").Split("-") @@ -125,14 +122,8 @@ $compFreeSpaceGB = "$compFreeSpaceGB" + ' GB' $compMemory = "$compMemory" + ' GB' - if (Get-SparkEnabled) { - $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 - } - } - + $locationData = Get-LocationDetails $comp + $i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID $props = [Ordered]@{ @@ -158,6 +149,7 @@ 'TPM Status' = "$tpmStatus" 'MBAM GPO' = "$getGPOStatus" Printers = "$getPrinter" + 'CMDB Location' = $locationData } $obj = New-Object -TypeName PSObject -Property $props diff --git a/Private/PCRemote.ps1 b/Private/PCRemote.ps1 index c7d73b7..462d42f 100644 --- a/Private/PCRemote.ps1 +++ b/Private/PCRemote.ps1 @@ -18,6 +18,8 @@ $compModel = Get-PCCompModel $comp $i++ | ProgressBar $i $comp "RAM Size" $NumberofComputers $PCID $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 $compFreeSpace = Get-PCCompFreeSpace $comp $i++ | ProgressBar $i $comp "Service Tag" $NumberofComputers $PCID @@ -40,8 +42,6 @@ $driveType = Get-PCDriveType $comp $i++ | ProgressBar $i $comp "Citrix Version" $NumberofComputers $PCID $citrixVersion = Get-PCCitrixVersion $comp - $i++ | ProgressBar $i $comp "CPU Type" $NumberofComputers $PCID - $compCPU = Get-CPUType $comp $i++ | ProgressBar $i $comp "Chassis Type" $NumberofComputers $PCID $chassisType = Get-ChassisType $compCPU $compModel @@ -130,6 +130,8 @@ $compFreeSpaceMB = "$compFreeSpaceMB" + ' MB' $compFreeSpaceGB = "$compFreeSpaceGB" + ' GB' $compMemory = "$compMemory" + ' GB' + + $locationData = Get-LocationDetails $comp $i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID @@ -156,6 +158,7 @@ 'TPM Status' = "$tpmStatus" 'MBAM GPO' = "$getGPOStatus" Printers = "$getPrinter" + 'CMDB Location' = $locationData } $obj = New-Object -TypeName PSObject -Property $props @@ -557,4 +560,30 @@ Function Get-TimeOutJob ($Command){ $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 } \ No newline at end of file diff --git a/Private/SCCMQuery.ps1 b/Private/SCCMQuery.ps1 index b919ff9..736e874 100644 --- a/Private/SCCMQuery.ps1 +++ b/Private/SCCMQuery.ps1 @@ -54,36 +54,36 @@ Function Get-SCCMQuery { 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 - $i++ | ProgressBar $i $comp "SCCM IP Query" $NumberofComputers $PCID + $i++; i++ | ProgressBar $i $comp "SCCM IP Query" $NumberofComputers $PCID $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 - $i++ | ProgressBar $i $comp "SCCM Bios Version" $NumberofComputers $PCID + $i++; i++ | ProgressBar $i $comp "SCCM Bios Version" $NumberofComputers $PCID $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 - $i++ | ProgressBar $i $comp "SCCM RAM" $NumberofComputers $PCID + $i++; i++ | ProgressBar $i $comp "SCCM RAM" $NumberofComputers $PCID $FindMemorySCCMGB = Get-SCCMFindMemoryQuery $comp $i++ | ProgressBar $i $comp "SCCM Asset Tag" $NumberofComputers $PCID $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 - $i++ | ProgressBar $i $comp "SCCM OS Name" $NumberofComputers $PCID + $i++; i++ | ProgressBar $i $comp "SCCM OS Name" $NumberofComputers $PCID $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 - $i++ | ProgressBar $i $comp "SCCM OS Build" $NumberofComputers $PCID + $i++; i++ | ProgressBar $i $comp "SCCM OS Build" $NumberofComputers $PCID $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 $i++ | ProgressBar $i $comp "SCCM Last Boot Up Time" $NumberofComputers $PCID $FindLastBootUpTimeSCCM = Get-SCCMLastBootUpTime $comp $i++ | ProgressBar $i $comp "SCCM Printers" $NumberofComputers $PCID $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 $i++ | ProgressBar $i $comp "SCCM Chassis Type" $NumberofComputers $PCID $FindChassisTypeSCCM = Get-SCCMChassisType($comp) diff --git a/Public/Get-PC.ps1 b/Public/Get-PC.ps1 index ac3e73c..eefe27c 100644 --- a/Public/Get-PC.ps1 +++ b/Public/Get-PC.ps1 @@ -4,7 +4,7 @@ #region Module Import Block -$ErrorActionPreference = 'SilentlyContinue' +#$ErrorActionPreference = 'SilentlyContinue' #DevStage can take either Dev or Prod as values $devStage = 'Dev' #Locations for dev build and prod build @@ -128,7 +128,6 @@ Function Get-PC { [Switch]$WinProfileRebuild ) - <# #Data collection for Get-PC Wrapped TM $invokeData = @{ Hostname = $env:COMPUTERNAME @@ -137,7 +136,6 @@ Function Get-PC { Parameters = $MyInvocation.BoundParameters } Add-Content -Path $getPCWrappedPath -Value $(ConvertTo-Json -Compress $invokeData) - #> ## Define which Spark Record Properties are Returned $Spark_Property_Return = @( @@ -670,5 +668,5 @@ Function Get-PC { } 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) } \ No newline at end of file diff --git a/patchnotes.txt b/patchnotes.txt index 2cfb4e6..aa09cee 100644 --- a/patchnotes.txt +++ b/patchnotes.txt @@ -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 -Add CMDB flag to just query CMDB for fields -Fix bug in CMDB Fallback not reporting RAM correctly