I\'m trying to write a very simple PowerShell script to give me the total number of items (both files and folders) in a given folder (c:\\MyFolder). Here\'s wh
You should use Measure-Object to count things. In this case it would look like:
Write-Host ( Get-ChildItem c:\MyFolder | Measure-Object ).Count;
or if that's too long
Write-Host ( dir c:\MyFolder | mo).Count;
and in PowerShell 4.0 use the measure alias instead of mo
Write-Host (dir c:\MyFolder | measure).Count;