Issue

Get-VaultFileBom returns only the first level of children even though the -Recursive parameter is set.


Cause

The -Recursive parameter is available in PowerShell currently, but it is not implemented yet.


Solution

To get the file BOM recursively you can write a recursive function yourself.


The following function calls Get-VaultFileBom recursively for all children until the cmdlet returns an empty array. This happens when no more children are available. For example on an .ipt file.

The return values are added to $fileBom and the variable is then returned at the end.


Note: This function doesn't calculate Bom_RowOrder! It is filled with bogus values!


Define the function

You can define the function directly in your script or in a module.


For example if you need this function a powerJobs Processor job you can save it in a module in "C:\ProgramData\coolOrange\powerJobs\Modules". When importing the powerJobs module it will also be imported.

function Get-VaultFileBomRecursive {
    param (
        $File
    )
    $fileBom = Get-VaultFileBom -File $File
    if(-not $fileBom) {
        return
    }
    foreach($fileBomRow in $fileBom) {
        $fileBom += Get-VaultFileBomRecursive -File $fileBomRow._FullPath
    }
    return $fileBom
}


Using the function

To use the function you can call it and pass the file path of the file that you want to retrieve the BOM from:

Import-module powerVault
Open-VaultConnection

$bomRecursive = Get-VaultFileBomRecursive -File '$/Designs/Padlock/Designs/Padlock/Assemblies/Pad Lock.iam'


See Also

PowerShell Functions (Microsoft docs)

File BomRow object (coolOrange wiki)