My code:
function Get-ChildItemRecursive { [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$FullName, [Parameter(Mandatory=$false)] [int]$Depth = 0 )
Process { if ($Depth -ne 1) { $newDepth = if ($Depth -gt 1) { $Depth - 1 } else { $Depth } Get-ChildItem -Path $FullName -Directory | Get-ChildItemRecursive -Depth $newDepth } Get-ChildItem -Path $FullName }
}
Get-ChildItemRecursive -FullName "$Home\Documents" -Depth 2 | Where {$.PSIsContainer -eq $True} | select Name, @{Name='Date Modified'; Expression={$.LastWriteTime.ToString('MM/dd/yyyy')}}, @{Name='Owner'; E={(($_.GetAccessControl().Owner.Split('\'))[1])}}, Fullname | Sort-Object FullName
smh.. I am using visual studio as well. forgot to add the closing } Anway it works! Thanks!