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
Gary Smith committed Aug 1, 2021
1 parent 2e56381 commit 381b72a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Format as below (Requires the '### Added' as a header or task fails)
...- Update ReadMe.MD

## [Unreleased]
### Added
- Get-InsightFullObjectType - ( ( $page -eq $results.pageSize ) -or ( !($results.objectEntries) ) )

## [1.22] - 2021-07-30
### Added
Expand Down
78 changes: 39 additions & 39 deletions JSM.Insight/Public/Get-InsightFullObjectType.ps1
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
}
}

0 comments on commit 381b72a

Please sign in to comment.