104 lines
4.7 KiB
PowerShell
104 lines
4.7 KiB
PowerShell
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
|
|
|
|
}
|