This worked fine. However, the article went on to say that this "feature" was "fixed" in V3 of Powershell and that the count property would indeed return a value of one if there was only one instance. I ran my code on two different machines, both with POSH V3 and it would not return a value of one.

Explanations?

by happysysadm at 2013-04-29 18:12:07

Hi David,

on v3 it works well for me: (gci).count with only one file returns 1, while on v2 it returned nothing.

Check $psversiontable and make sure your are effectively using v3.

Carlo

by Lembasts at 2013-04-29 18:33:52

I have checked $psversiontable and I am definitely using V3.

by MasterOfTheHat at 2013-05-01 08:29:19

Very strange... works like it's supposed to on mine:PS F:\Storage\Scripts\Windows\ScriptingGames> gci