In Powershell version 3 there is no way to limit the number of levels to do something in directories/registry/AD and so forth. So if you want to do that you can use a script like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [int] $Levels = "4" $Directory = "\\Directory" $List = GCI $Directory | Where { $_ .psiscontainer -eq $true } $Templist = $list $temp = @() While ( $levels -ne 1){ Foreach ( $item in $Templist ){ $Temp += gci $item .Fullname | Where { $_ .PSisContainer -eq $True }} $list += $Temp $Templist = $Temp $Levels -- $Temp =@()} $list = $list | Sort-Object Fullname Foreach ( $line in $List ){ Add-content -value $Line .Fullname -path ".\Export.csv" } |