I am trying to remove certain folders from the output fullname path.
In short, instead of H:/main/demo/first/ I would like something like this, /main/demo/first
Here is the code I am working with
Function Get-Depth {
Param(
[String]$Path = 'H:\main\',
[String]$Filter = "*",
[Int]$ToDepth = 1,
[Int]$CurrentDepth = 0
)
#incrimintation
$CurrentDepth++
Get-ChildItem $Path | %{
$_ | ?{ $_.Name -Like $Filter }
If ($_.PsIsContainer) {
If ($CurrentDepth -le $ToDepth) {
# Call to function
#adds the filter values and depth to the path..
Get-Depth -Path $_.FullName -Filter $Filter `
-ToDepth $ToDepth -CurrentDepth $CurrentDepth
}
}
}
}
Get-Depth|? {$_.PsIsContainer}| select @{Name='Date Modified'; Expression={$_.LastWriteTime.ToString('MM/dd/yyyy')}}, @{Name='Owner'; E={(($_.GetAccessControl().Owner.Split('\'))[1])}}, @{Name='Structure'; E={(($_.FullName.Split('\'))[-1])}}
The recommendation for aliasses is: It’s fine for the console for “quick 'n dirty” things, but do not use them in scripts. Never.
You can get a list of all alieasses with this: