Spark now utilized for CMDB Fallback
This commit is contained in:
parent
29e6749316
commit
5508b8fadc
|
|
@ -7,7 +7,7 @@ function Get-CMDBDELInfo {
|
||||||
if($null -eq $cmdb){
|
if($null -eq $cmdb){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if($cmdb.values.ConfigurationItem._SHSVendorPC -eq 'True'){
|
if($cmdb.SHS_IsVendorPC -eq 'True'){
|
||||||
$vendor = "Yes | Non-standard SHS Image/Hardware"
|
$vendor = "Yes | Non-standard SHS Image/Hardware"
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -15,9 +15,9 @@ function Get-CMDBDELInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
$delInfo = [PSCustomObject]@{
|
$delInfo = [PSCustomObject]@{
|
||||||
Owner = $cmdb.values.ConfigurationItem._SHSAssetOwner
|
Contact = $cmdb.SHS_ExceptionContact
|
||||||
Vendor = $vendor
|
Vendor = $vendor
|
||||||
Description = $cmdb.values.ConfigurationItem._Description
|
Description = $cmdb.AssignedDescription
|
||||||
}
|
}
|
||||||
|
|
||||||
return $delInfo
|
return $delInfo
|
||||||
|
|
|
||||||
|
|
@ -3,48 +3,34 @@ function Get-CMDBFallback {
|
||||||
$comp
|
$comp
|
||||||
)
|
)
|
||||||
|
|
||||||
$cmdbData = Get-LANDeskCMDBItem -name $comp
|
#$cmdbData = Get-LANDeskCMDBItem -name $comp
|
||||||
|
$cmdbData = Search-SparkCIs $comp
|
||||||
|
|
||||||
if(!$cmdbData){
|
$status = $cmdbData.Status
|
||||||
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
|
|
||||||
if(!$status){
|
if(!$status){
|
||||||
$status = 'No CMDB/SCCM Record Located'
|
$status = 'No CMDB/SCCM Record Located'
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$status = $cmdbData.values.Status + ' (CMDB Data)'
|
$status = $cmdbData.Status + ' (CMDB Data)'
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cmdbData.values._SHSLocation3.Length -gt $cmdbData.values._SHSCalcLocationString.Length){
|
$locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.LocationDetails
|
||||||
$locationData = $cmdbData.values._SHSLocation3
|
|
||||||
}
|
$phoneNumber = $cmdbData.LoginName
|
||||||
else{
|
|
||||||
$locationData = $cmdbData.values._SHSCalcLocationString
|
if($cmdbData.CIType -eq 'MobileDevice'){
|
||||||
}
|
|
||||||
if($cmdbData.values._ConfigTypesCategory -eq 'Mobile Device'){
|
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
Hostname = $cmdbData.values.Title
|
Hostname = $cmdbData.Name
|
||||||
'MAC' = $cmdbData.values._SHSMACAddress
|
'MAC' = $cmdbData.MACAddress
|
||||||
Model = $cmdbData.values._Model + ' (' + $cmdbData.Values._SHSChasisRef + ')'
|
Model = $cmdbData.Model + ' (' + $cmdbData.ChassisType + ')'
|
||||||
'OS' = $cmdbData.Values._SHSOperatingSystem
|
'OS' = $cmdbData.OperatingSystem
|
||||||
'Asset Tag' = $cmdbData.values._SHSAssetTag
|
'Asset Tag' = $cmdbData.AssetTag
|
||||||
'Service Tag' = $cmdbData.values._SerialNumber
|
'Service Tag' = $cmdbData.SerialNumber
|
||||||
'MDM Platform' = $cmdbData.values._SHSMDMPlatform
|
'MDM Platform' = $cmdbData.SHS_MdmPlatform
|
||||||
'Phone Number' = $cmdbData.values._SHSPhoneNumber
|
'Phone Number' = $cmdbData.PhoneNumber #TODO fix this, idk why Spark! doesn't return this
|
||||||
'Cellular Carrier' = $cmdbData.values._SHSCellularCarrier
|
'Cellular Carrier' = $cmdbData.SHS_Carrier
|
||||||
'Cellular Voice' = $cmdbData.values._SHSCellularVoice
|
'Cellular Voice' = $cmdbData.SHS_IsCellularVoice
|
||||||
'Cellular Data' = $cmdbData.values._SHSCellularData
|
'Cellular Data' = $cmdbData.SHS_IsCellularData
|
||||||
'CMDB Location' = $locationData
|
'CMDB Location' = $locationData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,9 +42,9 @@ function Get-CMDBFallback {
|
||||||
Status = $status
|
Status = $status
|
||||||
'Current User' = "Not Available"
|
'Current User' = "Not Available"
|
||||||
'Last User(s)' = $null
|
'Last User(s)' = $null
|
||||||
'IP | MAC' = $cmdbData.values._IPAddress + " | " + $cmdbData.values._SHSMACAddress
|
'IP | MAC' = $cmdbData.IPAddress + " | " + $cmdbData.MACAddress
|
||||||
Model = $cmdbData.values._Model + ' (' + $cmdbData.Values._SHSChasisRef + ')'
|
Model = $cmdbData.Model + ' (' + $cmdbData.ChassisType + ')'
|
||||||
'OS' = $cmdbData.Values._SHSOperatingSystem
|
'OS' = $cmdbData.OperatingSystem
|
||||||
'OS Build' = $null
|
'OS Build' = $null
|
||||||
'BIOS Ver' = $null
|
'BIOS Ver' = $null
|
||||||
Encryption = $null
|
Encryption = $null
|
||||||
|
|
@ -66,8 +52,8 @@ function Get-CMDBFallback {
|
||||||
RAM = $cmdbData.Values._RAM + " GB "
|
RAM = $cmdbData.Values._RAM + " GB "
|
||||||
'SSO Client' = "Not Available"
|
'SSO Client' = "Not Available"
|
||||||
'Kiosk Role' = "Not Available"
|
'Kiosk Role' = "Not Available"
|
||||||
'Asset Tag' = $cmdbData.values._SHSAssetTag
|
'Asset Tag' = $cmdbData.AssetTag
|
||||||
'Service Tag' = $cmdbData.values._SerialNumber
|
'Service Tag' = $cmdbData.SerialNumber
|
||||||
'Last Reboot' = $null
|
'Last Reboot' = $null
|
||||||
Printers = $null
|
Printers = $null
|
||||||
'CMDB Location' = $locationData
|
'CMDB Location' = $locationData
|
||||||
|
|
@ -78,9 +64,9 @@ function Get-CMDBFallback {
|
||||||
|
|
||||||
Write-Host "`n`nPulling cached CMDB data for $comp." -ForegroundColor Yellow
|
Write-Host "`n`nPulling cached CMDB data for $comp." -ForegroundColor Yellow
|
||||||
Write-Host "Last CMDB Update: ",$cmdbData.values.LastUpdate -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
|
$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 Vendor PC' -Value $delInfo.Vendor
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
|
$obj | Add-Member -MemberType NoteProperty -Name 'DEL Description' -Value $delInfo.Description
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,3 +43,13 @@ Function Check-SparkEnabled {
|
||||||
return -not -not $SparkHeaders["Authorization"]
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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 '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
|
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
|
#endregion
|
||||||
|
|
||||||
Function Get-PC {
|
Function Get-PC {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue