From 3f880a769f3264312efb82c81c9fda25367e3b9c Mon Sep 17 00:00:00 2001 From: "Mark B. Rasmussen" <56847489+Mark5900@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:10:46 +0100 Subject: [PATCH 1/2] fix: #455 --- .../Dev/Get-CapaUnitRelations.ps1 | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 b/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 index 2370be57..a125cbb9 100644 --- a/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 +++ b/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 @@ -23,41 +23,40 @@ Additional information about the function. #> function Get-CapaUnitRelations { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - $CapaSDK, - [Parameter(Mandatory = $true)] - $UnitName, - [Parameter(Mandatory = $true)] - [ValidateSet('Computer', 'User')] - $UnitType - ) - - $oaUnits = @() - - $aUnits = $CapaSDK.GetUnitRelations($UnitName, $UnitType) - - foreach ($sItem in $aUnits) { - $aItem = $sItem.Split(';') - $oaUnits += [pscustomobject]@{ - RelationType = $aItem[0]; - Name = $aItem[1]; - Created = $aItem[2]; - LastExecuted = $aItem[3]; - Status = $aItem[4]; - Description = $aItem[5]; - GUID = $aItem[7]; - ID = $aItem[8]; - TypeName = $aItem[9]; - UUID = $aItem[10]; - IsMobile = $aItem[11]; - Location = $aItem[12]; - CmpId = $aItem[13]; - BuId = $aItem[14] - } - } - - Return $oaUnit -} + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + $CapaSDK, + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + $UnitName, + [Parameter(Mandatory = $true)] + [ValidateSet('Computer', 'User')] + $UnitType + ) + + process { + # Retrieve unit relations using the Capa SDK + $CapaSDK.GetUnitRelations($UnitName, $UnitType) | ForEach-Object { + # Split the relation string into its components + $aItem = $_.Split(';') + # Create and return a custom object with the relation details + [pscustomobject]@{ + RelationType = $aItem[0]; + Name = $aItem[1]; + Created = $aItem[2]; + LastExecuted = $aItem[3]; + Status = $aItem[4]; + Description = $aItem[5]; + GUID = $aItem[7]; + ID = $aItem[8]; + TypeName = $aItem[9]; + UUID = $aItem[10]; + IsMobile = $aItem[11]; + Location = $aItem[12]; + CmpId = $aItem[13]; + BuId = $aItem[14] + } + } + } +} \ No newline at end of file From ac6b56c01b26eaa93caa4ad0d2ebc9d54b4dd956 Mon Sep 17 00:00:00 2001 From: "Mark B. Rasmussen" <56847489+Mark5900@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:15:28 +0100 Subject: [PATCH 2/2] Update Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Dev/Get-CapaUnitRelations.ps1 | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 b/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 index a125cbb9..c9f43785 100644 --- a/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 +++ b/Modules/Capa.PowerShell.Module.SDK.Unit/Dev/Get-CapaUnitRelations.ps1 @@ -23,40 +23,40 @@ Additional information about the function. #> function Get-CapaUnitRelations { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - $CapaSDK, - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - $UnitName, - [Parameter(Mandatory = $true)] - [ValidateSet('Computer', 'User')] - $UnitType - ) - - process { - # Retrieve unit relations using the Capa SDK - $CapaSDK.GetUnitRelations($UnitName, $UnitType) | ForEach-Object { - # Split the relation string into its components - $aItem = $_.Split(';') - # Create and return a custom object with the relation details - [pscustomobject]@{ - RelationType = $aItem[0]; - Name = $aItem[1]; - Created = $aItem[2]; - LastExecuted = $aItem[3]; - Status = $aItem[4]; - Description = $aItem[5]; - GUID = $aItem[7]; - ID = $aItem[8]; - TypeName = $aItem[9]; - UUID = $aItem[10]; - IsMobile = $aItem[11]; - Location = $aItem[12]; - CmpId = $aItem[13]; - BuId = $aItem[14] - } - } - } + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + $CapaSDK, + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + $UnitName, + [Parameter(Mandatory = $true)] + [ValidateSet('Computer', 'User')] + $UnitType + ) + + process { + # Retrieve unit relations using the Capa SDK + $CapaSDK.GetUnitRelations($UnitName, $UnitType) | ForEach-Object { + # Split the relation string into its components + $aItem = $_.Split(';') + # Create and return a custom object with the relation details + [pscustomobject]@{ + RelationType = $aItem[0]; + Name = $aItem[1]; + Created = $aItem[2]; + LastExecuted = $aItem[3]; + Status = $aItem[4]; + Description = $aItem[5]; + GUID = $aItem[7]; + ID = $aItem[8]; + TypeName = $aItem[9]; + UUID = $aItem[10]; + IsMobile = $aItem[11]; + Location = $aItem[12]; + CmpId = $aItem[13]; + BuId = $aItem[14] + } + } + } } \ No newline at end of file