# \-Recurse not working

**URL:** <https://forums.powershell.org/t/recurse-not-working/21278>\
**Category:** PowerShell Help\
**Created:** [January 4, 2023, 2:11pm UTC](https://forums.powershell.org/t/recurse-not-working/21278 "2023-01-04T14:11:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nitalis88](https://avatars.discourse-cdn.com/v4/letter/n/a88e57/32.png) [@Nitalis88](https://forums.powershell.org/u/Nitalis88)\
**Post date:** [January 4, 2023, 2:11pm UTC](https://forums.powershell.org/t/recurse-not-working/21278/1 "2023-01-04T14:11:53Z")

</div>

I have a script that will output the permissions of folders. The script will run fine is pointed at a specific directory, but if the -recurse option is used there are errors. Here is the code for recurse:

#===========================================================================

# Get permissions

#===========================================================================

$FolderPath = @()  
$FolderPath += Get-Item -Path $Path  
if ($Recurse.IsPresent)  
{  
$FolderPath += Get-ChildItem -Path $Path -Recurse -Force | ?{ $\_.PSIsContainer }  
}

$Permissions = @()  
ForEach ($Folder in $FolderPath)  
{  
$Acl = Get-Acl -Path $Folder.FullName  
ForEach ($Access in $Acl.Access)  
{  
$Properties = @{‘Folder Name’=$Folder.FullName;‘Identity’=$Access.IdentityReference;‘Permissions’=$Access.FileSystemRights;‘Inherited’=$Access.IsInherited;‘InheritanceFlags’=$Access.InheritanceFlags}  
$Permissions += New-Object -TypeName PSObject -Property $Properties  
}  
}

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 4, 2023, 2:27pm UTC](https://forums.powershell.org/t/recurse-not-working/21278/2 "2023-01-04T14:27:00Z")

</div>

Nick,  
Welcome to the forum. 👋🏽

> [@Nitalis88](#):
>
> there are errors

Errors are an important language feature helping you knowing what’s wrong with your code. So if you get errors you should share them here completely formatted as code.

Speaking of the code formatting … When you post code, sample data, console output or error messages please format it as code using the _preformatted text_ button ( **\</\>** ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

[How to format code in PowerShell.org](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif) \<---- Click 👆🏽 😉

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/recurse-not-working/21278/3 "2024-05-16T20:16:06Z")

</div>

Closed on May 16, 2024, 8:16pm UTC


