IMJLA / Export-Permission

Create CSV, HTML, and XML reports of permissions
MIT License
5 stars 1 forks source link

If all ACE identities filtered out by Get-FolderPermissionBlock, errors result #48

Closed IMJLA closed 10 months ago

IMJLA commented 10 months ago

Expected Behavior

No errors, just a report with no identities listed due to filtering

Current Behavior

...

DEBUG:   2024-01-14T06:41:18.1432       TestPC    TestPC\User      Permission.psm1: line 146       Export-FolderPermissionHtml     146     Debug   Get-FolderPermissionsBlock @GetFolderPermissionsBlock
InvalidOperation: Index operation failed; the array index evaluated to null.
InvalidOperation: Index operation failed; the array index evaluated to null.
Get-Member: You must specify an object for the Get-Member cmdlet.
Get-Member: You must specify an object for the Get-Member cmdlet.

...

DEBUG:   2024-01-14T06:41:18.4227       TestPC    TestPC\User      Permission.psm1: line 282       Export-FolderPermissionHtml     282     Debug   Get-HtmlBody -FolderList $JsonFolderList -HtmlFolderPermissions $FormattedFolderPermissions.JsonDiv
ConvertTo-BootstrapTableScript: Cannot bind argument to parameter 'DataJson' because it is an empty string.
ConvertTo-BootstrapTableScript: Cannot bind argument to parameter 'DataJson' because it is an empty string.

...

Steps to Reproduce (for bugs)

.\Export-Permission.ps1
IMJLA commented 10 months ago

bug resolved in 0.0.176 which incorporates v0.0.63 of the Permission module

workaround implemented was to send a dummy object down the pipeline

closing bug, but adding new issue as enhancement to dig deeper into this behavior and implement a better solution

    # Bugfix #48 https://github.com/IMJLA/Export-Permission/issues/48
    # Sending a dummy object down the line to avoid errors
    # TODO: More elegant solution needed. Downstream code should be able to handle null input.
    # TODO: Why does this suppress errors, but the object never appears in the tables?
    if ($null -eq $FilteredAccounts) {
        $FilteredAccounts = [pscustomobject]@{
            'Name'  = 'NoAccountsMatchingCriteria'
            'Group' = [pscustomobject]@{
                'IdentityReference' = '.'
                'Access'            = '.'
                'Name'              = '.'
                'Department'        = '.'
                'Title'             = '.'
            }
        }
    }