Get-PC/Private/Get-CMDBFallback.ps1
Zachary Gorman f3e8186b1c Spark, yay!
2024-08-02 12:03:04 -07:00

74 lines
2.8 KiB
PowerShell

function Get-CMDBFallback {
param (
$comp
)
#$cmdbData = Get-LANDeskCMDBItem -name $comp
$cmdbData = Get-SparkCI $comp
$status = $cmdbData.Status
if(!$status){
$status = 'No CMDB/SCCM Record Located'
}
else{
$status = $cmdbData.Status + ' (CMDB Data)'
}
$locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.SHS_LocationDetails
$phoneNumber = $cmdbData.LoginName
if($cmdbData.CIType -eq 'MobileDevice'){
$props = [Ordered]@{
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
}
$obj = New-Object -TypeName PSObject -Property $props
}
else{
$props = [Ordered]@{
Hostname = "$comp"
Status = $status
'Current User' = "Not Available"
'Last User(s)' = $null
'IP | MAC' = $cmdbData.IPAddress + " | " + $cmdbData.MACAddress
Model = $cmdbData.Model + ' (' + $cmdbData.ChassisType + ')'
'OS' = $cmdbData.OperatingSystem
'OS Build' = $null
'BIOS Ver' = $null
Encryption = $null
'Free Space' = $cmdbData.Values._AvailableDiskSpace + ' GB / ' + $cmdbData.Values._HardDiskSize + ' GB'
RAM = $cmdbData.Values._RAM + " GB "
'SSO Client' = "Not Available"
'Kiosk Role' = "Not Available"
'Asset Tag' = $cmdbData.AssetTag
'Service Tag' = $cmdbData.SerialNumber
'Last Reboot' = $null
Printers = $null
'CMDB Location' = $locationData
}
$obj = New-Object -TypeName PSObject -Property $props
}
Write-Host "`n`nPulling cached CMDB data for $comp." -ForegroundColor Yellow
Write-Host "Last CMDB Update: ",$cmdbData.values.LastUpdate -ForegroundColor Yellow
if($cmdbData.SHS_IsException -eq 'True'){
$delInfo = Get-CMDBDELInfo $cmdbData
$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
}
return $obj
}