diff --git a/Private/BatchInvokes.ps1 b/Private/BatchInvokes.ps1 index 5f90c83..2b1d24e 100644 --- a/Private/BatchInvokes.ps1 +++ b/Private/BatchInvokes.ps1 @@ -5,6 +5,8 @@ function Get-PCBatchInvoke { [string[]] $Computers ) + $SparkEnabled = Get-SparkEnabled + if ($SparkEnabled) { Connect-ISM } #Region Script Block $sblock = { 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"} } + 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 #Output @@ -328,6 +358,14 @@ function Get-PCBatchInvoke { $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 '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 } diff --git a/Private/Connect-LANDesk.ps1 b/Private/Connect-LANDesk.ps1 deleted file mode 100644 index 9d3f38c..0000000 --- a/Private/Connect-LANDesk.ps1 +++ /dev/null @@ -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 -} - - diff --git a/Private/Get-CMDBFallback.ps1 b/Private/Get-CMDBFallback.ps1 index e66f3d4..c3229c3 100644 --- a/Private/Get-CMDBFallback.ps1 +++ b/Private/Get-CMDBFallback.ps1 @@ -4,7 +4,7 @@ function Get-CMDBFallback { ) #$cmdbData = Get-LANDeskCMDBItem -name $comp - $cmdbData = Search-SparkCIs $comp + $cmdbData = Get-SparkCI $comp $status = $cmdbData.Status if(!$status){ @@ -14,7 +14,7 @@ function Get-CMDBFallback { $status = $cmdbData.Status + ' (CMDB Data)' } - $locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.LocationDetails + $locationData = $cmdbData.SHS_Floor + ' - ' + $cmdbData.SHS_Department + ' - ' + $cmdbData.SHS_LocationDetails $phoneNumber = $cmdbData.LoginName diff --git a/Private/Get-LANDeskCMDBItem.ps1 b/Private/Get-LANDeskCMDBItem.ps1 deleted file mode 100644 index c03d4e4..0000000 --- a/Private/Get-LANDeskCMDBItem.ps1 +++ /dev/null @@ -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 - -} diff --git a/Private/PCLocal.ps1 b/Private/PCLocal.ps1 index 8f1fd58..68295a7 100644 --- a/Private/PCLocal.ps1 +++ b/Private/PCLocal.ps1 @@ -124,6 +124,14 @@ $compFreeSpaceMB = "$compFreeSpaceMB" + ' MB' $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 + } + } $i++ | ProgressBar $i $comp "Generating Output" $NumberofComputers $PCID @@ -153,6 +161,14 @@ } $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 } diff --git a/Private/Search-CMDB.ps1 b/Private/Search-CMDB.ps1 deleted file mode 100644 index e8ba2bc..0000000 --- a/Private/Search-CMDB.ps1 +++ /dev/null @@ -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 - -} \ No newline at end of file diff --git a/Private/Set-CMDBLocation.ps1 b/Private/Set-CMDBLocation.ps1 deleted file mode 100644 index c106c67..0000000 --- a/Private/Set-CMDBLocation.ps1 +++ /dev/null @@ -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 { - } -} \ No newline at end of file diff --git a/Private/Spark.ps1 b/Private/Spark.ps1 index c3fa75d..541d7d4 100644 --- a/Private/Spark.ps1 +++ b/Private/Spark.ps1 @@ -39,13 +39,15 @@ Function Connect-ISM { } } -Function Check-SparkEnabled { +if ($(Read-Host "Enable Spark features? (y/N)") -match "^y") { Connect-ISM } + +Function Get-SparkEnabled { return -not -not $SparkHeaders["Authorization"] } -Function Search-SparkCIs($CIName) { +Function Get-SparkCI($CIName) { Connect-ISM - $uri = "$SparkURL/api/odata/businessobject/CIs`?`$filter=Name+eq+%27$CIName%27&`$top=100&`$skip=0" + $uri = "$SparkURL/api/odata/businessobject/CIs`?`$filter=Name+eq+%27$CIName%27" try{ $Query = Invoke-RestMethod -Method GET -uri $uri -headers $SparkHeaders } catch { diff --git a/Public/Get-PC.ps1 b/Public/Get-PC.ps1 index d4893aa..884ba3c 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,8 +27,6 @@ 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 { @@ -92,6 +90,7 @@ Function Get-PC { [Switch]$Bypass, [Switch]$ClearCCMCache, [switch]$Devices, + [switch]$EnableSpark, [Switch]$EventLog, [switch]$Excel, [Switch]$FileSystem, @@ -137,6 +136,8 @@ Function Get-PC { Update-GetPC return } + + if ($EnableSpark) { Connect-ISM } if ($PatchNotes) { $scriptparent = (get-item $PSScriptRoot ).parent.FullName diff --git a/patchnotes.txt b/patchnotes.txt index 5764aeb..52d8368 100644 --- a/patchnotes.txt +++ b/patchnotes.txt @@ -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-26 -Refactors -Update BatchInvokes to utilize jobs for up to 4x speedup