# encoding: ascii
# api: powershell
# title: Powershell Scripting
# description: Can anyone help me here and explain the below code
# version: 0.1
# type: function
# author: Praveen
# license: CC0
# x-poshcode-id: 5789
# x-archived: 2016-03-06T00:48:23
# x-published: 2016-03-17T10:44:00
#
#
function filecount {
param (
[string]$path
)
if (-not (Test-Path $path)){Throw "Path: $path not found"}
$count = 0
$count = Get-ChildItem -Path $path |
where {!$_.PSIsContainer} |
Measure-Object |
select -Expand count
Get-Item -Path $path |
select PSDrive,
##@{N="Parent"; E={($_.PSParentPath -split "FileSystem::")[1]}},
Name,
@{N="FileCount"; E={$count}} | Where-Object { !($_ -match 'psa4ruww') }
Get-ChildItem -Path $path |
where {$_.PSIsContainer} |
foreach {
filecount $($_.Fullname)
}
}
filecount "dir path"