Merge branch 'Spark'
This commit is contained in:
commit
ebc72b3f40
|
|
@ -5,6 +5,8 @@ function Get-PCBatchInvoke {
|
||||||
[string[]]
|
[string[]]
|
||||||
$Computers
|
$Computers
|
||||||
)
|
)
|
||||||
|
$SparkEnabled = Get-SparkEnabled
|
||||||
|
if ($SparkEnabled) { Connect-ISM }
|
||||||
#Region Script Block
|
#Region Script Block
|
||||||
$sblock = {
|
$sblock = {
|
||||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 10
|
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 10
|
||||||
|
|
@ -300,6 +302,34 @@ function Get-PCBatchInvoke {
|
||||||
Default {$chassisType = "Unknown Model/Chassis"}
|
Default {$chassisType = "Unknown Model/Chassis"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (${using:SparkEnabled}) {
|
||||||
|
$uri = "${using:SparkURL}/api/odata/businessobject/CIs`?`$filter=Name+eq+%27$($Env:COMPUTERNAME)%27"
|
||||||
|
try{
|
||||||
|
$Query = Invoke-RestMethod -Method GET -uri $uri -headers ${using:SparkHeaders}
|
||||||
|
} catch {
|
||||||
|
$ExceptionErrors += $_.Exception.Message
|
||||||
|
}
|
||||||
|
$cmdbData = $Query.Value
|
||||||
|
|
||||||
|
if ($cmdbData.SHS_IsException -eq 'True') {
|
||||||
|
Write-host "***NOTICE: $($Env:COMPUTERNAME) is a Device Exception computer. Please check CMDB/Asset Mgmt prior to supporting this workstation. ***" -BackgroundColor Black -ForegroundColor Yellow
|
||||||
|
if($cmdb.SHS_IsVendorPC -eq 'True'){
|
||||||
|
$vendor = "Yes | Non-standard SHS Image/Hardware"
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$vendor = "No | Standard SHS Hardware"
|
||||||
|
}
|
||||||
|
|
||||||
|
$delInfo = [PSCustomObject]@{
|
||||||
|
Contact = $cmdbData.SHS_ExceptionContact
|
||||||
|
Vendor = $vendor
|
||||||
|
Description = $cmdbData.AssignedDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.SHS_LocationDetails
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 90
|
Write-Progress -Activity "Retrieving data from online computers" -Status $Env:COMPUTERNAME -PercentComplete 90
|
||||||
#Output
|
#Output
|
||||||
|
|
@ -328,6 +358,14 @@ function Get-PCBatchInvoke {
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'TPM Status' -Value "$tpmStatus"
|
$obj | Add-Member -MemberType NoteProperty -Name 'TPM Status' -Value "$tpmStatus"
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'MBAM GPO' -Value "$gpostatus"
|
$obj | Add-Member -MemberType NoteProperty -Name 'MBAM GPO' -Value "$gpostatus"
|
||||||
$obj | Add-Member -MemberType NoteProperty -Name 'Printers' -Value "$printers"
|
$obj | Add-Member -MemberType NoteProperty -Name 'Printers' -Value "$printers"
|
||||||
|
if (${using:SparkEnabled}) {
|
||||||
|
$obj | Add-Member -MemberType NoteProperty -Name 'CMDB Location' -Value "$locationData"
|
||||||
|
}
|
||||||
|
if ($delInfo) {
|
||||||
|
$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
|
return $obj
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
function Connect-LANDesk {
|
|
||||||
[CmdletBinding()]
|
|
||||||
param (
|
|
||||||
[Parameter(HelpMessage = 'The Server of landesk',
|
|
||||||
Mandatory = $false)]
|
|
||||||
[string]$server = "shsldapp1",
|
|
||||||
[Parameter(HelpMessage = 'The Framework',
|
|
||||||
Mandatory = $false)]
|
|
||||||
[string]$framework = "ServiceDeskAPI",
|
|
||||||
[Parameter(HelpMessage = 'The Framework',
|
|
||||||
Mandatory = $false)]
|
|
||||||
[string]$username = $env:username,
|
|
||||||
[Parameter(HelpMessage = 'The password used to connect',
|
|
||||||
Mandatory = $false)]
|
|
||||||
[String]$Pass = ''
|
|
||||||
)
|
|
||||||
if($env:username -like "jrodriguez.adm"){
|
|
||||||
$username = "jorodriguez"
|
|
||||||
}
|
|
||||||
elseif($env:username -like "*.adm"){
|
|
||||||
$username = $env:USERNAME.Split('.')[0]
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$username = "$env:username"
|
|
||||||
}
|
|
||||||
$pair = "$($username):$($Pass)"
|
|
||||||
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
|
|
||||||
$basicAuthValue = "Basic $encodedCreds"
|
|
||||||
$headers = @{}
|
|
||||||
$headers["Authorization"] = $basicAuthValue
|
|
||||||
$headers["Accept"] = "application/landesk.ldms.base+json,application/json"
|
|
||||||
$headers["Accept-Language"] = "en-US,en;q=0.8"
|
|
||||||
|
|
||||||
Return $headers, $server, $framework
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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 = Get-SparkCI $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.SHS_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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
||||||
function Get-LANDeskCMDBItem {
|
|
||||||
[CmdletBinding(DefaultParameterSetName="Default")]
|
|
||||||
param (
|
|
||||||
[Parameter(HelpMessage = 'Search LANDesk CMDB by the Name of the CMDM Item',
|
|
||||||
ParameterSetName = 'Title',
|
|
||||||
Mandatory = $true
|
|
||||||
)]
|
|
||||||
[string]$Name,
|
|
||||||
[Parameter(HelpMessage = 'Search LANDesk CMDB by the Configuration Item Type',
|
|
||||||
ParameterSetName = '_ConfigTypesCategory',
|
|
||||||
Mandatory = $true
|
|
||||||
)]
|
|
||||||
[string]$CIType,
|
|
||||||
[Parameter(HelpMessage = 'Search for the CMDB Item by Asset Tag Number',
|
|
||||||
ParameterSetName = '_SHSAssetTag',
|
|
||||||
Mandatory = $true
|
|
||||||
)]
|
|
||||||
[string]$AssetTag,
|
|
||||||
[Parameter(HelpMessage = 'Search for the Request by Current Assigned Group in LANDesk',
|
|
||||||
ParameterSetName = 'Default',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true
|
|
||||||
)]
|
|
||||||
[switch]$All,
|
|
||||||
[Parameter(HelpMessage = 'Specifying Server',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $server = $(Connect-LANDesk)[1],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $framework = $(Connect-LANDesk)[2],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[hashtable] $Headers = $(Connect-LANDesk)[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
$uri = 'http://' + $server + '/' + $framework + '/api/'
|
|
||||||
#$SearchURI = $uri + 'query/?class_name=_CMDBManagement.Call&page_size=20000000&attributes=Title,_ConfigTypesCategory,Status,_SHSDeleted,_SHSDeployedTo,_SHSCIPrimaryOwner,_PO,_SHSAssetTag,_CILocation,_RequestID,_IPAddress,_SerialNumber,_Department,_Model,_Manufacture,_SHSTier,_SHSAssetOwner,_SHSLocation3,_SHSWarrantyExpires,_SHSPOANumber,_SHSEpicPrinterWorkflow,_SHSLastAuditDate,_SHSEnvironment,Description,_IncidentQueue,_RequestQueue,_SHSCINotes,CreationDate,CreationUser,LastUpdate,LastUpdateUser,_SHSOperatingSystem,_SHSChassisType,_HardDiskSize,_RAM,_AvailableDiskSpace,_Model,_SHSKioskRoleName,_SerialNumber,_IPAddress,_SHSOSPatching,_SHSPatchSchedule,_SHSPatchNotes,_SHSDeviceExceptionContact,_SHSDeviceExceptionContact,_DisplayName&V=*'
|
|
||||||
$SearchURI = $uri + 'query/?class_name=_CMDBManagement.Call&page_size=20000000&attributes=Title,_ConfigTypesCategory,ConfigurationItem._Description,_SHSCalcLocationString,_SHSPhoneNumber,_SHSMDMPlatform,_SHSCellularCarrier,_SHSCellularVoice,_SHSCellularData,ConfigurationItem._SHSDELAsset,ConfigurationItem._SHSVendorPC,ConfigurationItem._SHSAssetOwner,Status,_SHSDeleted,_SHSDeployedTo,_SHSCIPrimaryOwner,_PO,_SHSAssetTag,_CILocation,_RequestID,_IPAddress,_SerialNumber,_Department,_Model,_Manufacture,_SHSTier,_SHSAssetOwner,_SHSLocation3,_SHSWarrantyExpires,_SHSPOANumber,_SHSEpicPrinterWorkflow,_SHSLastAuditDate,_SHSEnvironment,Description,_IncidentQueue,_RequestQueue,_SHSCINotes,CreationDate,CreationUser,LastUpdate,LastUpdateUser,_SHSOperatingSystem,_SHSChassisType,_SHSChasisRef,_HardDiskSize,_RAM,_AvailableDiskSpace,_Model,_SHSKioskRoleName,_SerialNumber,_IPAddress,_SHSMACAddress,_LocationDetails,_DisplayName&V=*'
|
|
||||||
|
|
||||||
if (($PSCmdlet.ParameterSetName -ne "Default") -and ($PSCmdlet.ParameterSetName -ne "_ConfigTypesCategory") ) {
|
|
||||||
$FinalUri = $SearchURI + '&cns=' + $PSCmdlet.ParameterSetName + '-e-0-_a__SHSDeleted-e-1&c0=' + $PSBoundParameters.Values + '&c1=False'
|
|
||||||
}
|
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq "_ConfigTypesCategory") {
|
|
||||||
if ($PSBoundParameters.Values -eq 'Workstation') {
|
|
||||||
$FinalUri = $SearchURI + '&cns=' + $PSCmdlet.ParameterSetName + '-e-0-_a__SHSDeleted-e-1&c0=' + '9dadd9f9-ca5d-4be6-93cc-6c8745fff615' + '&c1=False'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Printer
|
|
||||||
$FinalUri = $SearchURI + '&cns=' + $PSCmdlet.ParameterSetName + '-e-0-_a__SHSDeleted-e-1&c0=' + 'd1e6d576-a18f-4703-b431-c859f1c222ee' + '&c1=False'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Verbose "DEfault"
|
|
||||||
$FinalUri = $SearchURI
|
|
||||||
}
|
|
||||||
|
|
||||||
$SearchResults = (Invoke-RestMethod -Uri $FinalUri -Headers $headers -Method get).DataRows
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $SearchResults
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function Get-CMDBData {
|
|
||||||
[CmdletBinding()]
|
|
||||||
param (
|
|
||||||
[Parameter()]
|
|
||||||
[string]
|
|
||||||
$comp,
|
|
||||||
|
|
||||||
[string]
|
|
||||||
$asset
|
|
||||||
)
|
|
||||||
|
|
||||||
if($asset -match "\w \w"){
|
|
||||||
$asset = $asset -split ' '
|
|
||||||
$asset = $asset[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
$cmdb = Get-LANDeskCMDBItem -Name $comp
|
|
||||||
if ($null -eq $cmdb){
|
|
||||||
try { $cmdb = Get-LANDeskCMDBItem -AssetTag $asset} catch{ $cmdb = $null }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $cmdb
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -125,6 +125,14 @@
|
||||||
$compFreeSpaceGB = "$compFreeSpaceGB" + ' GB'
|
$compFreeSpaceGB = "$compFreeSpaceGB" + ' GB'
|
||||||
$compMemory = "$compMemory" + ' 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID
|
$i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID
|
||||||
|
|
||||||
$props = [Ordered]@{
|
$props = [Ordered]@{
|
||||||
|
|
@ -153,6 +161,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = New-Object -TypeName PSObject -Property $props
|
$obj = New-Object -TypeName PSObject -Property $props
|
||||||
|
if ($locationData) {
|
||||||
|
$obj | Add-Member -MemberType NoteProperty -Name 'CMDB Location' -Value $locationData
|
||||||
|
}
|
||||||
|
if ($delInfo) {
|
||||||
|
$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
|
return $obj
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
function Search-CMDB{
|
|
||||||
|
|
||||||
[CmdletBinding()]
|
|
||||||
param (
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Search LANDesk CMDB by the Name of the CMDM Item'
|
|
||||||
)]
|
|
||||||
[string]$Hostname,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Search for the CMDB Item by Asset Tag Number'
|
|
||||||
)]
|
|
||||||
[string]$AssetTag,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Search for the CMDB Item by Location'
|
|
||||||
)]
|
|
||||||
[string]$Location,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Search for the CMDB Item by Guid/Key'
|
|
||||||
)]
|
|
||||||
[string]$key,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Specifying Server',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $server = $(Connect-LANDesk)[1],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $framework = $(Connect-LANDesk)[2],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[hashtable] $Headers = $(Connect-LANDesk)[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
if(($Hostname + $AssetTag + $Location + $key) -eq ''){
|
|
||||||
Write-Warning 'Input cannot be null'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$attributes = @(
|
|
||||||
'Guid',
|
|
||||||
'Title',
|
|
||||||
'_ConfigTypesCategory',
|
|
||||||
'Status',
|
|
||||||
'_SHSAssetTag',
|
|
||||||
'_SerialNumber',
|
|
||||||
'_Model',
|
|
||||||
'ConfigurationItem',
|
|
||||||
'ConfigurationItem.Guid',
|
|
||||||
'ConfigurationItem._SHSDELAsset',
|
|
||||||
'ConfigurationItem._SHSVendorPC',
|
|
||||||
'CreationDate',
|
|
||||||
'CreationUser',
|
|
||||||
'LastUpdate',
|
|
||||||
'LastUpdateUser',
|
|
||||||
'Lifecycle',
|
|
||||||
'_LocationDetails',
|
|
||||||
'_SHSLocation3',
|
|
||||||
'_SHSCINotes',
|
|
||||||
'_SHSCIPrimaryOwner',
|
|
||||||
'_SHSSCCMScanDate',
|
|
||||||
'_SHSChassisType',
|
|
||||||
'_SHSPOANumber'
|
|
||||||
)
|
|
||||||
|
|
||||||
$attributesString = $attributes -join ','
|
|
||||||
|
|
||||||
$uri = 'http://' + $server + '/' + $framework + '/api/'
|
|
||||||
$searchUri = $uri + 'query/?class_name=_CMDBManagement.Call&page_size=20000000&attributes=' + $attributesString + '&v=*' + '&cns=' + '_SHSDeleted-e-0_a_' + 'Title' + '-c-1_a_' + '_SHSLocation3' +'-c-2-&c0=False&c1=' + $Hostname + '&c2=' + $Location
|
|
||||||
$SearchResults = (Invoke-RestMethod -Uri $searchUri -Headers $headers -Method get).DataRows
|
|
||||||
|
|
||||||
$output = @()
|
|
||||||
if($SearchResults -is [array]){
|
|
||||||
foreach($result in $SearchResults){
|
|
||||||
$cmdbRecord = [PSCustomObject]@{
|
|
||||||
Hostname = $result.values.Title
|
|
||||||
AssetTag = $result.values._SHSAssetTag
|
|
||||||
Status = $result.values.Status
|
|
||||||
Type = $result.values._ConfigTypesCategory
|
|
||||||
Model = $result.values._Model
|
|
||||||
Chassis = $result.values._SHSChassisType
|
|
||||||
SerialNumber = $result.values._SerialNumber
|
|
||||||
POA = $result.values._SHSPOANumber
|
|
||||||
Location = $result.values._SHSLocation3
|
|
||||||
CreationDate = $result.values.CreationDate
|
|
||||||
CreationUser = $result.values.CreationUser
|
|
||||||
LastUpdate = $result.values.LastUpdate
|
|
||||||
LastUpdateUser = $result.values.LastUpdateUser
|
|
||||||
Lifecycle = $result.values.Lifecycle
|
|
||||||
Guid = $result.Key
|
|
||||||
CI = $result.values.ConfigurationItem
|
|
||||||
}
|
|
||||||
$output += $cmdbRecord
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$output = [PSCustomObject]@{
|
|
||||||
Hostname = $SearchResults.values.Title
|
|
||||||
AssetTag = $SearchResults.values._SHSAssetTag
|
|
||||||
Status = $SearchResults.values.Status
|
|
||||||
Type = $SearchResults.values._ConfigTypesCategory
|
|
||||||
Model = $SearchResults.values._Model
|
|
||||||
Chassis = $SearchResults.values._SHSChassisType
|
|
||||||
SerialNumber = $SearchResults.values._SerialNumber
|
|
||||||
POA = $SearchResults.values._SHSPOANumber
|
|
||||||
Location = $SearchResults.values._SHSLocation3
|
|
||||||
CreationDate = $SearchResults.values.CreationDate
|
|
||||||
CreationUser = $SearchResults.values.CreationUser
|
|
||||||
LastUpdate = $SearchResults.values.LastUpdate
|
|
||||||
LastUpdateUser = $SearchResults.values.LastUpdateUser
|
|
||||||
Lifecycle = $SearchResults.values.Lifecycle
|
|
||||||
Guid = $SearchResults.Key
|
|
||||||
CI = $SearchResults.values.ConfigurationItem
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output | Select-Object -Property Hostname, Type, Location
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,368 +0,0 @@
|
||||||
function Set-CMDBLocation {
|
|
||||||
[CmdletBinding()]
|
|
||||||
param (
|
|
||||||
[Parameter()]
|
|
||||||
[string]
|
|
||||||
$Hostname
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try { $cmdbData = Get-LANDeskCMDBItem -Name $Hostname } catch { $cmdbData = $null}
|
|
||||||
if($null -eq $cmdbData){
|
|
||||||
$getpcData = Get-PCBatchInvoke $Hostname
|
|
||||||
$asset = $getpcData.'Asset Tag'
|
|
||||||
$asset = $asset -split ' '
|
|
||||||
$asset = $asset[0]
|
|
||||||
try { $cmdbData = Get-LANDeskCMDBItem -AssetTag $asset} catch{ $cmdbData = $null }
|
|
||||||
if($null -eq $cmdbData){
|
|
||||||
Write-Warning "Unable to find record with that hostname or assset tag in CMDB"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$oldLocation = $cmdbData.Values._SHSLocation3
|
|
||||||
$key = $cmdbData.key
|
|
||||||
Write-Host "Hostname: $hostname"
|
|
||||||
Write-Host "Current Location: $oldLocation"
|
|
||||||
$newLocation = Read-Host "New Location"
|
|
||||||
|
|
||||||
try {Set-LANDeskCMDBWorkstation -LocationDetails $newLocation -Key $key | Out-Null }
|
|
||||||
catch {
|
|
||||||
Write-Warning "Unable to change location data"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try { $cmdbData = Get-LANDeskCMDBItem -Name $Hostname } catch { $cmdbData = $null}
|
|
||||||
if($null -eq $cmdbData){
|
|
||||||
try { $cmdbData = Get-LANDeskCMDBItem -AssetTag $asset} catch{ $cmdbData = $null }
|
|
||||||
if($null -eq $cmdbData){
|
|
||||||
Write-Warning "Unable to find record with that hostname or assset tag in CMDB"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newLocation = $cmdbData.values._SHSLocation3
|
|
||||||
Write-Host "Location now set to: $newLocation" -ForegroundColor Green
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-LANDeskCMDBLocation {
|
|
||||||
[CmdletBinding(DefaultParameterSetName="Default")]
|
|
||||||
param (
|
|
||||||
[Parameter(HelpMessage = 'The Name of the new CMDB item',
|
|
||||||
Mandatory = $true
|
|
||||||
)]
|
|
||||||
[string]$Name,
|
|
||||||
[Parameter(HelpMessage = 'Enter the Location Details for the CMDB Item')]
|
|
||||||
[string]$LocationDetails,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the GUID for the CMDB Item')]
|
|
||||||
[string]$Key,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Specifying Server',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $server = $(Connect-LANDesk)[1],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $framework = $(Connect-LANDesk)[2],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[hashtable] $Headers = $(Connect-LANDesk)[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
[object[]]$Values = $null
|
|
||||||
|
|
||||||
$Title = @{}
|
|
||||||
$Title.Name = "Title"
|
|
||||||
$Title.Value = $Name
|
|
||||||
[object[]]$Values += $Title
|
|
||||||
|
|
||||||
<#
|
|
||||||
$_ConfigTypesCategory = @{}
|
|
||||||
$_ConfigTypesCategory.Name = "_ConfigTypesCategory"
|
|
||||||
$_ConfigTypesCategory.Value = '9dadd9f9-ca5d-4be6-93cc-6c8745fff615'
|
|
||||||
$Values += $_ConfigTypesCategory
|
|
||||||
#>
|
|
||||||
$LocationDetails
|
|
||||||
$_SHSLocation3 = @{}
|
|
||||||
$_SHSLocation3.Name = "_SHSLocation3"
|
|
||||||
$_SHSLocation3.Value = $LocationDetails
|
|
||||||
$Values += $_SHSLocation3
|
|
||||||
|
|
||||||
$body = [ordered]@{}
|
|
||||||
$body.class_name = '_CMDBManagement.Call'
|
|
||||||
$Body.originalValues = $Values
|
|
||||||
$body.formValues = $Values
|
|
||||||
$body = $body | ConvertTo-Json
|
|
||||||
|
|
||||||
$uri = 'http://' + $server + '/' + $framework + '/api/form?class_name=_CMDBManagement.Call&key=' + $Key + '&function_name=Edit&v=*'
|
|
||||||
Invoke-RestMethod -Uri $uri -Headers $headers -Body $Body -Method Patch
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-LANDeskCMDBWorkstation {
|
|
||||||
[CmdletBinding(DefaultParameterSetName="Default")]
|
|
||||||
param (
|
|
||||||
[Parameter(HelpMessage = 'The Name of the new CMDB item')]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the PO for the CMDB Item')]
|
|
||||||
[string]$PO,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Physical Location for the CMDB Item')]
|
|
||||||
[string]$PhysicalLocation,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Asset Tag for the CMDB Item')]
|
|
||||||
[string]$AssetTag,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the RequestID for the CMDB Item')]
|
|
||||||
[string]$RequestID,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the OperatingSystem for the CMDB Item')]
|
|
||||||
[string]$OperatingSystem,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the ChassisType for the CMDB Item')]
|
|
||||||
[string]$ChassisType,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Total Hard Drive Size for the CMDB Item')]
|
|
||||||
[string]$HDD,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the RAM for the CMDB Item')]
|
|
||||||
[string]$RAM,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Hard drive space Avalible for the CMDB Item')]
|
|
||||||
[string]$HDDAvail,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the IPAddress for the CMDB Item')]
|
|
||||||
[string]$IPAddress,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the KioskRole for the CMDB Item')]
|
|
||||||
[string]$KioskRole,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Model for the CMDB Item')]
|
|
||||||
[string]$Model,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the SerialNumber for the CMDB Item')]
|
|
||||||
[string]$SerialNumber,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Notes for the CMDB Item')]
|
|
||||||
[string]$Notes,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the OSPatching for the CMDB Item')]
|
|
||||||
[string]$OSPatching,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Patch Schedule for the CMDB Item')]
|
|
||||||
[string]$PatchSchedule,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Patch Notes for the CMDB Item')]
|
|
||||||
[string]$PatchNotes,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the Location Details for the CMDB Item')]
|
|
||||||
[string]$LocationDetails,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Enter the GUID for the CMDB Item',
|
|
||||||
Mandatory = $true)]
|
|
||||||
[string]$Key,
|
|
||||||
|
|
||||||
[Parameter(HelpMessage = 'Specifying Server',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $server = $(Connect-LANDesk)[1],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Framework for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[string] $framework = $(Connect-LANDesk)[2],
|
|
||||||
[Parameter(HelpMessage = 'Specifying LanDesk Headers for api',
|
|
||||||
Mandatory = $false,
|
|
||||||
DontShow = $true)]
|
|
||||||
[hashtable] $Headers = $(Connect-LANDesk)[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
[object[]]$Values = $null
|
|
||||||
|
|
||||||
if($Name){
|
|
||||||
$Title = @{}
|
|
||||||
$Title.Name = "Title"
|
|
||||||
$Title.Value = $Name
|
|
||||||
[object[]]$Values += $Title
|
|
||||||
}
|
|
||||||
|
|
||||||
<# $_ConfigTypesCategory = @{}
|
|
||||||
$_ConfigTypesCategory.Name = "_ConfigTypesCategory"
|
|
||||||
$_ConfigTypesCategory.Value = '9dadd9f9-ca5d-4be6-93cc-6c8745fff615'
|
|
||||||
$Values += $_ConfigTypesCategory #>
|
|
||||||
|
|
||||||
if ($PO) {
|
|
||||||
$_PO = @{}
|
|
||||||
$_PO.Name = "_PO"
|
|
||||||
$_PO.Value = $PO
|
|
||||||
$Values += $_PO
|
|
||||||
}
|
|
||||||
|
|
||||||
# Look up table
|
|
||||||
if ($PhysicalLocation) {
|
|
||||||
$Location = Search-LANDeskIssueLocation -Location $PhysicalLocation
|
|
||||||
$_CILocation = @{}
|
|
||||||
$_CILocation.Name = "_CILocation"
|
|
||||||
$_CILocation.Value = $Location.Key
|
|
||||||
$Values += $_CILocation
|
|
||||||
}
|
|
||||||
if ($AssetTag) {
|
|
||||||
$_SHSAssetTag = @{}
|
|
||||||
$_SHSAssetTag.Name = "_SHSAssetTag"
|
|
||||||
$_SHSAssetTag.Value = $AssetTag
|
|
||||||
$Values += $_SHSAssetTag
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($RequestID) {
|
|
||||||
$_RequestID = @{}
|
|
||||||
$_RequestID.Name = "_RequestID"
|
|
||||||
$_RequestID.Value = $RequestID
|
|
||||||
$Values += $_RequestID
|
|
||||||
}
|
|
||||||
# Look up table
|
|
||||||
if ($OperatingSystem) {
|
|
||||||
if($OperatingSystem -match 'Windows 10'){
|
|
||||||
$OS = '2ad72fd5-8d4e-4510-b5ea-f94b3a2cda08'
|
|
||||||
}
|
|
||||||
elseif ($OperatingSystem -match 'Windows 7') {
|
|
||||||
$OS = 'f127ceee-074b-4cc1-8a71-f8c02a9a9bd1'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$OS = '00000000-0000-0000-0000-000000000000'
|
|
||||||
}
|
|
||||||
$_SHSOperatingSystem = @{}
|
|
||||||
$_SHSOperatingSystem.Name = "_SHSOperatingSystem"
|
|
||||||
$_SHSOperatingSystem.Value = $OS
|
|
||||||
$Values += $_SHSOperatingSystem
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ChassisType) {
|
|
||||||
if($ChassisType -match "Desktop" -or $ChassisType -match "SFF"){
|
|
||||||
$ChassisGuid = 'c7f3c5ba-a8b3-40be-963f-7e1d75fb7fda'
|
|
||||||
}
|
|
||||||
elseif ($ChassisType -match "Micro") {
|
|
||||||
$ChassisGuid = '8d71a4c3-ae9d-4e55-98ea-2f8a75987cac'
|
|
||||||
}
|
|
||||||
elseif($ChassisType -match "Laptop"){
|
|
||||||
$ChassisGuid = 'a8460b18-bab9-4c07-8fb1-a4cca4e63fa1'
|
|
||||||
}
|
|
||||||
elseif($ChassisType -match "Tablet"){
|
|
||||||
$ChassisGuid = 'e6ae9cd4-9936-496d-8e5d-efce8417a3d0'
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$ChassisGuid = '00000000-0000-0000-0000-000000000000'
|
|
||||||
}
|
|
||||||
$_SHSChassisType = @{}
|
|
||||||
$_SHSChassisType.Name = "_SHSChasisRef"
|
|
||||||
$_SHSChassisType.Value = $ChassisGuid
|
|
||||||
$Values += $_SHSChassisType
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($HDD) {
|
|
||||||
$_HardDiskSize = @{}
|
|
||||||
$_HardDiskSize.Name = "_HardDiskSize"
|
|
||||||
$_HardDiskSize.Value = $HDD
|
|
||||||
$Values += $_HardDiskSize
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($RAM) {
|
|
||||||
$_RAM = @{}
|
|
||||||
$_RAM.Name = "_RAM"
|
|
||||||
$_RAM.Value = $RAM
|
|
||||||
$Values += $_RAM
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($HDDAvail) {
|
|
||||||
$_AvailableDiskSpace = @{}
|
|
||||||
$_AvailableDiskSpace.Name = "_AvailableDiskSpace"
|
|
||||||
$_AvailableDiskSpace.Value = $HDDAvail
|
|
||||||
$Values += $_AvailableDiskSpace
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($IPAddress) {
|
|
||||||
$_IPAddress = @{}
|
|
||||||
$_IPAddress.Name = "_IPAddress"
|
|
||||||
$_IPAddress.Value = $IPAddress
|
|
||||||
$Values += $_IPAddress
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($Model) {
|
|
||||||
$_Model = @{}
|
|
||||||
$_Model.Name = "_Model"
|
|
||||||
$_Model.Value = $Model
|
|
||||||
$Values += $_Model
|
|
||||||
}
|
|
||||||
if ($SerialNumber) {
|
|
||||||
$_SerialNumber = @{}
|
|
||||||
$_SerialNumber.Name = "_SerialNumber"
|
|
||||||
$_SerialNumber.Value = $SerialNumber
|
|
||||||
$Values += $_SerialNumber
|
|
||||||
}
|
|
||||||
if ($Notes) {
|
|
||||||
$_SHSCINotes = @{}
|
|
||||||
$_SHSCINotes.Name = "_SHSCINotes"
|
|
||||||
$_SHSCINotes.Value = $Notes
|
|
||||||
$Values += $_SHSCINotes
|
|
||||||
}
|
|
||||||
# Look up table
|
|
||||||
if ($OSPatching) {
|
|
||||||
$Patch = Search-LANDeskOSPatchType -PatchType $OSPatching
|
|
||||||
$_SHSOSPatching = @{}
|
|
||||||
$_SHSOSPatching.Name = "_SHSOSPatching"
|
|
||||||
$_SHSOSPatching.Value = $Patch.Key
|
|
||||||
$Values += $_SHSOSPatching
|
|
||||||
}
|
|
||||||
#look up table
|
|
||||||
if ($PatchSchedule) {
|
|
||||||
$Schedule = Get-LANDeskPatchSchedule -PatchSchedule $PatchSchedule
|
|
||||||
$_SHSPatchSchedule = @{}
|
|
||||||
$_SHSPatchSchedule.Name = "_SHSPatchSchedule"
|
|
||||||
$_SHSPatchSchedule.Value = $Schedule
|
|
||||||
$Values += $_SHSPatchSchedule
|
|
||||||
}
|
|
||||||
if ($PatchNotes) {
|
|
||||||
$_SHSPatchNotes = @{}
|
|
||||||
$_SHSPatchNotes.Name = "_SHSPatchNotes"
|
|
||||||
$_SHSPatchNotes.Value = $PatchNotes
|
|
||||||
$Values += $_SHSPatchNotes
|
|
||||||
}
|
|
||||||
if ($LocationDetails){
|
|
||||||
$LocationDetails
|
|
||||||
$_SHSLocation3 = @{}
|
|
||||||
$_SHSLocation3.Name = "_SHSLocation3"
|
|
||||||
$_SHSLocation3.Value = $LocationDetails
|
|
||||||
$Values += $_SHSLocation3
|
|
||||||
}
|
|
||||||
|
|
||||||
$body = [ordered]@{}
|
|
||||||
$body.class_name = '_CMDBManagement.Call'
|
|
||||||
$Body.originalValues = $Values
|
|
||||||
$body.formValues = $Values
|
|
||||||
$body = $body | ConvertTo-Json
|
|
||||||
|
|
||||||
$uri = 'http://' + $server + '/' + $framework + '/api/form?class_name=_CMDBManagement.Call&key=' + $Key + '&function_name=Edit&v=*'
|
|
||||||
Invoke-RestMethod -Uri $uri -Headers $headers -Body $Body -Method Patch
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
57
Private/Spark.ps1
Normal file
57
Private/Spark.ps1
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
$SparkHeaders = @{
|
||||||
|
"Content-Type" = "application/json"
|
||||||
|
"Authorization" = ""
|
||||||
|
"Accept" = "*/*"
|
||||||
|
"Accept-Encoding" = "gzip, deflate, br"
|
||||||
|
}
|
||||||
|
|
||||||
|
$SparkTenantPrefix = "samaritanhealth-amc"
|
||||||
|
$SparkURL = "https://$SparkTenantPrefix.ivanticloud.com"
|
||||||
|
|
||||||
|
Function Connect-ISM {
|
||||||
|
try {
|
||||||
|
#Try a fast route to check if authorization headers are set properly
|
||||||
|
Invoke-RestMethod -Method Get -URI "$SparkURL/api/odata" -Headers $SparkHeaders
|
||||||
|
} catch {
|
||||||
|
$errobject = ConvertFrom-Json $_
|
||||||
|
#A 404 means we were authorized and didn't find anything, as intended!
|
||||||
|
if ($errobject.code -eq "ISM_4004") { return }
|
||||||
|
#Anything other than a 401 Unauthorized is unexpected, attempt to handle gracefully
|
||||||
|
if ($errobject.code -ne "ISM_4001") {
|
||||||
|
Write-Host -ForegroundColor Red "Unexpected error connecting to Spark!"
|
||||||
|
Write-Host -ForegroundColor Red "$errobject"
|
||||||
|
$SparkHeaders["Authorization"] = ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
#Unuathorized response, so let's update our authorization!
|
||||||
|
if ( $SparkHeaders["Authorization"] ) {
|
||||||
|
Write-Host "Spark Authorization key expired, please update key"
|
||||||
|
}
|
||||||
|
$authKey = Read-Host "Login to Spark, open browser dev tools, and paste SID cookie here, or an API key if you have one"
|
||||||
|
if ($authKey -match "[0-9A-F](32)") {
|
||||||
|
$SparkHeaders["Authorization"] = "rest_api_key=$authKey"
|
||||||
|
} elseif ($authKey -match "$($SparkURL.split('/')[-1])#.*#") {
|
||||||
|
$SparkHeaders["Authorization"] = $authKey
|
||||||
|
} else {
|
||||||
|
Write-Host -ForegroundColor Yellow "Authorization key not a recognized key format"
|
||||||
|
$SparkHeaders["Authorization"] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(Read-Host "Enable Spark features? (y/N)") -match "^y") { Connect-ISM }
|
||||||
|
|
||||||
|
Function Get-SparkEnabled {
|
||||||
|
return -not -not $SparkHeaders["Authorization"]
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-SparkCI($CIName) {
|
||||||
|
Connect-ISM
|
||||||
|
$uri = "$SparkURL/api/odata/businessobject/CIs`?`$filter=Name+eq+%27$CIName%27"
|
||||||
|
try{
|
||||||
|
$Query = Invoke-RestMethod -Method GET -uri $uri -headers $SparkHeaders
|
||||||
|
} catch {
|
||||||
|
$ExceptionErrors += $_.Exception.Message
|
||||||
|
}
|
||||||
|
return $Query.Value
|
||||||
|
}
|
||||||
|
|
@ -90,6 +90,7 @@ Function Get-PC {
|
||||||
[Switch]$Bypass,
|
[Switch]$Bypass,
|
||||||
[Switch]$ClearCCMCache,
|
[Switch]$ClearCCMCache,
|
||||||
[switch]$Devices,
|
[switch]$Devices,
|
||||||
|
[switch]$EnableSpark,
|
||||||
[Switch]$EventLog,
|
[Switch]$EventLog,
|
||||||
[switch]$Excel,
|
[switch]$Excel,
|
||||||
[Switch]$FileSystem,
|
[Switch]$FileSystem,
|
||||||
|
|
@ -136,6 +137,8 @@ Function Get-PC {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($EnableSpark) { Connect-ISM }
|
||||||
|
|
||||||
if ($PatchNotes) {
|
if ($PatchNotes) {
|
||||||
$scriptparent = (get-item $PSScriptRoot ).parent.FullName
|
$scriptparent = (get-item $PSScriptRoot ).parent.FullName
|
||||||
Write-Host "`n"
|
Write-Host "`n"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
Patch: 2024-08-02
|
||||||
|
-Remove references to LANDesk
|
||||||
|
-Add interface to CMDB via Spark!
|
||||||
|
-Add CMDB data to output
|
||||||
|
-Add DEL warning and info
|
||||||
|
|
||||||
Patch: 2024-07-30
|
Patch: 2024-07-30
|
||||||
-Fix SCCM scans that broke in last update. Woopsie!
|
-Fix SCCM scans that broke in last update. Woopsie!
|
||||||
-Add stronger filters to AppDiff
|
-Add stronger filters to AppDiff
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue