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 what I've done:
Write-Host ( Get-ChildItem c:\MyFolder ).Count;
The problem is, that if I have 1 or 0 items, the command does not work---it returns nothing.
Any ideas?
Write-Host @( Get-ChildItem c:\MyFolder ).Count;. This keeps older versions of Powershell from collapsing/unwrapping the list/array returned byGet-ChildItemwhen there's less than 2 elements in it.