IMJLA / Export-Permission

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

Get-FolderAccessList, Get-Item, and the root share of UNC paths #27

Closed IMJLA closed 2 years ago

IMJLA commented 2 years ago

$Permissions = Get-FolderAccessList @AclParams -FolderTargets $FolderTargets

    # If $ThisTargetPath was on a local disk such as C:\
    # The Get-FolderTarget cmdlet has replaced that local disk path with the corresponding UNC path \\$(hostname)\C$
    # If $ThisTargetPath is the root of that local disk, Get-FolderAccessList's dependency Get-Item cannot retrieve a DirectoryInfo object for the root of the share
    # (error: "Could not find item")
    # As a workaround here we will instead get the folder ACL for the original $ThisTargetPath
    # But I don't think this solves it since it won't work for actual remote paths at the root of the share: \\server\share
    if ($null -eq $Permissions) {
        Write-LogMsg @LogParams -Text "Get-FolderAccessList -FolderTargets '$ThisTargetPath' -LevelsOfSubfolders $SubfolderLevels"
        $Permissions = Get-FolderAccessList @AclParams -FolderTargets $ThisTargetPath
    }
IMJLA commented 2 years ago

Cannot reproduce. Get-FolderAccessList dependency on Get-Item appears to have been removed