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
1 parent
fa36a4d
commit 8efa095
Showing
3 changed files
with
493 additions
and
485 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,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 | ||
} | ||
} |
Oops, something went wrong.