PoshCode Archive  Artifact [a00f1d1092]

Artifact a00f1d109240b166ca445ed5bb2308b128d1f014287e60c9e3b037a6b048d903:

  • File Powershell-Scripting.ps1 — part of check-in [6416ae180c] at 2018-06-10 14:01:26 on branch trunk — Can anyone help me here and explain the below code (user: Praveen size: 1190)

# 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"