fatboybubba
2007-03-05 13:52:17 UTC
I'm not sure whats happening here, hopefully someone can explain. I
am trying to get the count of the number of items contained within a
folder but it appears that when there is only 1 item get-childitem
returns $null. Is there a better way to do this?
Clearly there is a file here:
PS T:\> gci T:\users\rdean -Recurse
Directory: Microsoft.PowerShell.Core\FileSystem::T:\users\rdean
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2/8/2007 11:20 AM 619431 Poolmon3vbs.zip
But if I do the following the count property returns $null
PS T:\> (gci T:\users\rdean -Force).count
PS T:\>
PS T:\> if ((gci T:\users\rdean -Force).count -eq $null) { $true }
True
If I add a another item like the following the count property returns
2 like I would expect.
PS T:\> gci T:\users\rdean -Recurse
Directory: Microsoft.PowerShell.Core\FileSystem::T:\users\rdean
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/5/2007 8:43 AM New Folder
-a--- 2/8/2007 11:20 AM 619431 Poolmon3vbs.zip
PS T:\> (gci T:\users\rdean -Force).count
2
PS T:\>
Any ideas?
TIA
-Bob
am trying to get the count of the number of items contained within a
folder but it appears that when there is only 1 item get-childitem
returns $null. Is there a better way to do this?
Clearly there is a file here:
PS T:\> gci T:\users\rdean -Recurse
Directory: Microsoft.PowerShell.Core\FileSystem::T:\users\rdean
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2/8/2007 11:20 AM 619431 Poolmon3vbs.zip
But if I do the following the count property returns $null
PS T:\> (gci T:\users\rdean -Force).count
PS T:\>
PS T:\> if ((gci T:\users\rdean -Force).count -eq $null) { $true }
True
If I add a another item like the following the count property returns
2 like I would expect.
PS T:\> gci T:\users\rdean -Recurse
Directory: Microsoft.PowerShell.Core\FileSystem::T:\users\rdean
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/5/2007 8:43 AM New Folder
-a--- 2/8/2007 11:20 AM 619431 Poolmon3vbs.zip
PS T:\> (gci T:\users\rdean -Force).count
2
PS T:\>
Any ideas?
TIA
-Bob