Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
!Deploy!
Browse files Browse the repository at this point in the history
  • Loading branch information
DamagedDingo committed Aug 16, 2021
1 parent fa36a4d commit 8efa095
Show file tree
Hide file tree
Showing 3 changed files with 493 additions and 485 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Format as below (Requires the '### Added' as a header or task fails)
...- Update ReadMe.MD

## [Unreleased]
### Added
- Invoke-HostInfo REPLACEMENT FOR INSIGHT DISCOVERY AGENT WINDOWS ONLY
- Get-InsightFullObjectType updated with a fast option to ignore objects

## [1.23] - 2021-08-01
### Added
Expand Down
81 changes: 43 additions & 38 deletions JSM.Insight/Public/Get-InsightFullObjectType.ps1
Original file line number Diff line number Diff line change
@@ -1,47 +1,52 @@
# Custom Function to Get Object Type, Attributes, and All Objects
function Get-InsightFullObjectType {
[CmdletBinding()]
param (
[string]$ObjectSchemaName,
[string]$ObjectTypeName
)
[CmdletBinding()]
param (
[string]$ObjectSchemaName,
[string]$ObjectTypeName,
[switch]$NoObjects
)

begin {
Write-PSFMessage -Level Host -Message "Starting 'Get-InsightFullObjectType'" -Tag 'Get-InsightFullObjectType'
begin {
Write-PSFMessage -Level Host -Message "Starting 'Get-InsightFullObjectType'" -Tag 'Get-InsightFullObjectType'

$ObjectSchema = (Get-InsightObjectSchemaList).values | Where-Object { $_.name -eq $ObjectSchemaName }
$ObjectSchemaObjectTypes = Get-InsightObjectSchemaObjectTypes -ID $ObjectSchema.id
$ObjectSchema = (Get-InsightObjectSchemaList).values | Where-Object { $_.name -eq $ObjectSchemaName }
$ObjectSchemaObjectTypes = Get-InsightObjectSchemaObjectTypes -ID $ObjectSchema.id

$JSMObjects = @()
$objs = @()
$page = 0
$JSMObjects = @()
$objs = @()
$page = 0

class JSMexport {
[string]$name
[Object]$objectType
[Object]$attributes
[Object]$objects
}
}
class JSMexport {
[string]$name
[Object]$objectType
[Object]$attributes
[Object]$objects
}
}

process {
$e = [JSMexport]::New()
$e.objectType = Get-InsightObjectType -ID $($ObjectSchemaObjectTypes | Where-Object { $_.name -eq $ObjectTypeName }).id
$e.attributes = Get-InsightObjectTypeAttributes -ID $($ObjectSchemaObjectTypes | Where-Object { $_.name -eq $ObjectTypeName }).id
#Loop through and return all objects. IncludeAttributes to get 'attributes and values' for the objects themselves
do {
$page++
Write-PSFMessage -Level Host -Message "Preforming 'Find-InsightObject' on page: $page" -Tag 'Get-InsightFullObjectType'
$results = Find-InsightObject -objectSchemaId $ObjectSchema.id -objectTypeId $e.objectType.id -resultsPerPage 2000 -page $page -IQL ${objectType = "$ObjectTypeName"} -includeAttributes $true
$objs += $results.objectEntries
} until ( ( $page -eq $results.pageSize ) -or ( !($results.objectEntries) ) )
$e.objects = $objs
$e.name = $e.objectType.name
$JSMObjects += $e
}
process {
$e = [JSMexport]::New()
$e.objectType = Get-InsightObjectType -ID $($ObjectSchemaObjectTypes | Where-Object { $_.name -eq $ObjectTypeName }).id
$e.attributes = Get-InsightObjectTypeAttributes -ID $($ObjectSchemaObjectTypes | Where-Object { $_.name -eq $ObjectTypeName }).id
#Loop through and return all objects. IncludeAttributes to get 'attributes and values' for the objects themselves

if ($NoObjects -eq $false) {
do {
$page++
Write-PSFMessage -Level Host -Message "Preforming 'Find-InsightObject' on page: $page" -Tag 'Get-InsightFullObjectType'
$results = Find-InsightObject -objectSchemaId $ObjectSchema.id -objectTypeId $e.objectType.id -resultsPerPage 2000 -page $page -IQL ${objectType = "$ObjectTypeName"} -includeAttributes $true
$objs += $results.objectEntries
} until ( ( $page -eq $results.pageSize ) -or ( !($results.objectEntries) ) )
$e.objects = $objs
}

$e.name = $e.objectType.name
$JSMObjects += $e
}

end {
Write-PSFMessage -Level Host -Message "Completed 'Get-InsightFullObjectType'" -Tag 'Get-InsightFullObjectType'
$JSMObjects
}
end {
Write-PSFMessage -Level Host -Message "Completed 'Get-InsightFullObjectType'" -Tag 'Get-InsightFullObjectType'
$JSMObjects
}
}
Loading

0 comments on commit 8efa095

Please sign in to comment.