diff --git a/Private/Get-CMDBDELInfo.ps1 b/Private/Get-CMDBDELInfo.ps1 index 9de7307..ffe65df 100644 --- a/Private/Get-CMDBDELInfo.ps1 +++ b/Private/Get-CMDBDELInfo.ps1 @@ -7,7 +7,7 @@ function Get-CMDBDELInfo { if($null -eq $cmdb){ return } - if($cmdb.values.ConfigurationItem._SHSVendorPC -eq 'True'){ + if($cmdb.SHS_IsVendorPC -eq 'True'){ $vendor = "Yes | Non-standard SHS Image/Hardware" } else{ @@ -15,9 +15,9 @@ function Get-CMDBDELInfo { } $delInfo = [PSCustomObject]@{ - Owner = $cmdb.values.ConfigurationItem._SHSAssetOwner + Contact = $cmdb.SHS_ExceptionContact Vendor = $vendor - Description = $cmdb.values.ConfigurationItem._Description + Description = $cmdb.AssignedDescription } return $delInfo diff --git a/Private/Get-CMDBFallback.ps1 b/Private/Get-CMDBFallback.ps1 index 59e9b72..e66f3d4 100644 --- a/Private/Get-CMDBFallback.ps1 +++ b/Private/Get-CMDBFallback.ps1 @@ -3,48 +3,34 @@ function Get-CMDBFallback { $comp ) - $cmdbData = Get-LANDeskCMDBItem -name $comp + #$cmdbData = Get-LANDeskCMDBItem -name $comp + $cmdbData = Search-SparkCIs $comp - if(!$cmdbData){ - if($comp.Length -gt 5){ - $asset = $comp[-5..-1] -join "" - $cmdbData = Get-LANDeskCMDBItem -AssetTag $asset - if($cmdbData){ - $comp = $cmdbData.values.Title - if(Test-Connection $comp){ - $getpcData = get-pc $comp - return $getpcData - } - } - } - } - $status = $cmdbData.values.Status + $status = $cmdbData.Status if(!$status){ $status = 'No CMDB/SCCM Record Located' } else{ - $status = $cmdbData.values.Status + ' (CMDB Data)' + $status = $cmdbData.Status + ' (CMDB Data)' } - if($cmdbData.values._SHSLocation3.Length -gt $cmdbData.values._SHSCalcLocationString.Length){ - $locationData = $cmdbData.values._SHSLocation3 - } - else{ - $locationData = $cmdbData.values._SHSCalcLocationString - } - if($cmdbData.values._ConfigTypesCategory -eq 'Mobile Device'){ + $locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.LocationDetails + + $phoneNumber = $cmdbData.LoginName + + if($cmdbData.CIType -eq 'MobileDevice'){ $props = [Ordered]@{ - Hostname = $cmdbData.values.Title - 'MAC' = $cmdbData.values._SHSMACAddress - Model = $cmdbData.values._Model + ' (' + $cmdbData.Values._SHSChasisRef + ')' - 'OS' = $cmdbData.Values._SHSOperatingSystem - 'Asset Tag' = $cmdbData.values._SHSAssetTag - 'Service Tag' = $cmdbData.values._SerialNumber - 'MDM Platform' = $cmdbData.values._SHSMDMPlatform - 'Phone Number' = $cmdbData.values._SHSPhoneNumber - 'Cellular Carrier' = $cmdbData.values._SHSCellularCarrier - 'Cellular Voice' = $cmdbData.values._SHSCellularVoice - 'Cellular Data' = $cmdbData.values._SHSCellularData + Hostname = $cmdbData.Name + 'MAC' = $cmdbData.MACAddress + Model = $cmdbData.Model + ' (' + $cmdbData.ChassisType + ')' + 'OS' = $cmdbData.OperatingSystem + 'Asset Tag' = $cmdbData.AssetTag + 'Service Tag' = $cmdbData.SerialNumber + 'MDM Platform' = $cmdbData.SHS_MdmPlatform + 'Phone Number' = $cmdbData.PhoneNumber #TODO fix this, idk why Spark! doesn't return this + 'Cellular Carrier' = $cmdbData.SHS_Carrier + 'Cellular Voice' = $cmdbData.SHS_IsCellularVoice + 'Cellular Data' = $cmdbData.SHS_IsCellularData 'CMDB Location' = $locationData } @@ -56,9 +42,9 @@ function Get-CMDBFallback { Status = $status 'Current User' = "Not Available" 'Last User(s)' = $null - 'IP | MAC' = $cmdbData.values._IPAddress + " | " + $cmdbData.values._SHSMACAddress - Model = $cmdbData.values._Model + ' (' + $cmdbData.Values._SHSChasisRef + ')' - 'OS' = $cmdbData.Values._SHSOperatingSystem + 'IP | MAC' = $cmdbData.IPAddress + " | " + $cmdbData.MACAddress + Model = $cmdbData.Model + ' (' + $cmdbData.ChassisType + ')' + 'OS' = $cmdbData.OperatingSystem 'OS Build' = $null 'BIOS Ver' = $null Encryption = $null @@ -66,8 +52,8 @@ function Get-CMDBFallback { RAM = $cmdbData.Values._RAM + " GB " 'SSO Client' = "Not Available" 'Kiosk Role' = "Not Available" - 'Asset Tag' = $cmdbData.values._SHSAssetTag - 'Service Tag' = $cmdbData.values._SerialNumber + 'Asset Tag' = $cmdbData.AssetTag + 'Service Tag' = $cmdbData.SerialNumber 'Last Reboot' = $null Printers = $null 'CMDB Location' = $locationData @@ -78,9 +64,9 @@ function Get-CMDBFallback { Write-Host "`n`nPulling cached CMDB data for $comp." -ForegroundColor Yellow Write-Host "Last CMDB Update: ",$cmdbData.values.LastUpdate -ForegroundColor Yellow - if($cmdbData.values.ConfigurationItem._SHSDELAsset -eq 'True'){ + if($cmdbData.SHS_IsException -eq 'True'){ $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.Contact $obj | Add-Member -MemberType NoteProperty -Name 'DEL Vendor PC' -Value $delInfo.Vendor $obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description } diff --git a/Private/Spark.ps1 b/Private/Spark.ps1 index d99bdd0..c3fa75d 100644 --- a/Private/Spark.ps1 +++ b/Private/Spark.ps1 @@ -43,3 +43,13 @@ Function Check-SparkEnabled { return -not -not $SparkHeaders["Authorization"] } +Function Search-SparkCIs($CIName) { + Connect-ISM + $uri = "$SparkURL/api/odata/businessobject/CIs`?`$filter=Name+eq+%27$CIName%27&`$top=100&`$skip=0" + try{ + $Query = Invoke-RestMethod -Method GET -uri $uri -headers $SparkHeaders + } catch { + $ExceptionErrors += $_.Exception.Message + } + return $Query.Value +} diff --git a/Public/Get-PC.ps1 b/Public/Get-PC.ps1 index c817143..d4893aa 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 @@ -27,6 +27,8 @@ if ($Version -ne $deployedVersion) { Write-Host 'New version of Get-PC is available. Please run Get-PC -Update' -ForegroundColor Yellow } Write-Host "Enter 'Help Get-PC' for available commands.`n" -ForegroundColor Green + +if ($(Read-Host "Enable Spark features? (y/N)") -match "^y") { Connect-ISM } #endregion Function Get-PC {