This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gary Smith
committed
Aug 1, 2021
1 parent
2e56381
commit 381b72a
Showing
2 changed files
with
41 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
# 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 | ||
) | ||
|
||
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).count -eq 0 ) ) | ||
$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 | ||
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 | ||
} | ||
} |