Get-ChildItem.Count not working with one file

I'm executing the following command on a directory that has one file in it.  
When I execute it, there is never a result.  Only when I add a second file 
does it come back with an answer.  any help?

(Get-ChildItem c:\temp\output *.csv).Count

If I run the normal Get-ChildItems c:\temp\output I do see one file listed.
0
Utf
1/14/2010 5:36:02 PM
windows.powershell 690 articles. 0 followers. Follow

2 Replies
2527 Views

Similar Articles

[PageSpeed] 28

Hello Steve,

> I'm executing the following command on a directory that has one file
> in it.  When I execute it, there is never a result.  Only when I add a
> second file does it come back with an answer.  any help?
> 
> (Get-ChildItem c:\temp\output *.csv).Count
> 
> If I run the normal Get-ChildItems c:\temp\output I do see one file
> listed.
> 

..Count only works on an array of objects.

When you have only 1 object, you don't have an array unless you specifically 
create an array:

@(Get-ChildItem c:\temp\output *.csv).count

Karl
http://unlockpowershell.wordpress.com/



0
Karl
1/14/2010 6:36:13 PM
If only one item is returned Powershell doesn't bother wrapping it in a 
collection so there is no count property.

Common workaround is to force it into an array.

@(Get-ChildItem c:\temp\output *.csv).Count 

This will work if there's 1 or 0 items returned.

-Paul


"steve" wrote:

> I'm executing the following command on a directory that has one file in it.  
> When I execute it, there is never a result.  Only when I add a second file 
> does it come back with an answer.  any help?
> 
> (Get-ChildItem c:\temp\output *.csv).Count
> 
> If I run the normal Get-ChildItems c:\temp\output I do see one file listed.
1
Utf
1/14/2010 6:46:01 PM
Reply:

Similar Artilces:

PUB File Viewer
Is there a PUB file viewer available? I have someone creating PUB files and sending them to me to review and I don't have Microsoft Publisher. Thanks in advance for any help... No, there not a Publisher Viewer. Have that person convert the file to a ,pdf and send you that for proofing. -- JoAnn Paules MVP Microsoft [Publisher] "Ray Mooney" <ray@mooney.net> wrote in message news:O7FjFXUjEHA.3612@TK2MSFTNGP12.phx.gbl... > Is there a PUB file viewer available? > > I have someone creating PUB files and sending them to me to review and I > don't have ...

Get error message 0x800CCC131 evreytime I try to send e-mail Can anybody h send
I assume you're using a Hotmail account? That error message is something saying that Outlook has sent a bad request. Generally, this comes from a proxy server or firewall that doesn't understand the HTTP/DAV protocol that is used to talk to Hotmail. I'd say that someone (either your ISP or your network administrator) recently installed or reconfigured a proxy server between you and the Internet. Contact the proper person and ask them to either upgrade or reconfigure in order to support HTTP/DAV. -- Jeff Stephenson Outlook Development This posting is provided "AS IS&quo...

How to count rows with changing data
I have an imported list on sheet2 and it is maybe 100 rows. Each day the data is imported the dates change along with the type of record associated with each date. Say this week there are 25 rows with 11/13, 20 rows with 11/14 and 25 rows with 11/15 and 30 rows with 11/16. Mixed in with this each of these dates might have a different type of record (each type has 4 options.) I need to be able to do the following: 1.) I need to count the number of occurrences for each date and not only show the total count but also show the date that is counted as the label. 2.)count the...

How to get Calendar to send me reminders
I have changed my e-mail address but for some reason I cannot get Calendar to send reminders to my new address - I think I have carried out all that is necessary to effect the changover but I am not getting reminders sent. Can anyone help please? Is the Calendar Live ID based and accessible at Calendar.live.com ? -- ....winston ms-mvp mail "Dabardevon" wrote in message = news:FDC2B3B2-EDE4-41B1-BFC4-C0F9ED59CFB9@microsoft.com... I have changed my e-mail address but for some reason I cannot get = Calendar to send reminders to my new address - I think I have...

How to print one header over several columns of data
I want to print one title over a span of columns - what is the command? Format>Cells>Aligment>Horizontal>Center across selection? Gord Dibben MS Excel MVP On Thu, 27 May 2010 14:19:00 -0700, column title print <column title print@discussions.microsoft.com> wrote: >I want to print one title over a span of columns - what is the command? ...

Send/Receive function stops working...?
Howdy, I run OL2000 with Win2K Pro. Often (perhaps twice a day) the send/receive button stops working. Specifically, on clicking the button, its look changes as if properly functioning, but then nothing further happens. The same is true if I attempt to launch a send/receive cycle from the menu. I cannot just send either. Re-booting solves the problem every time. What might this be about, and is there a solution? Sincere thanks, -- Kenneth If you email... Please remove the "SPAMLESS." ...

Access 2007 help file
I am using Access 2007. I cannot get any help information for Visual Basic. When in Visual Basic if I hit the help menu icon, I get an online help window to open, but every time I try to get information on "DAO reference" and follow the thread to the information I want, the answer screen is blank---i.e. no information at all; no words, no nothing! Did I install wrongly? Is this something new Turn off the option to search online help so that you are only using help from your computer. On the bottom right side of the online help screen, click the icon and change the ...

Query Tied to Form doesn't work
I have a button on a form that populates a text box on the same form with text. I have a query where a field's criteria is a reference to the text box on the form so the text in the text box becomes the criteria for the query. After I click the button to populate the text box on the form and then run the query, it comes up blank (should be records). If I click the button on the form and copy the text from the text box to the query (in stead of a reference to the text box on the form) the query works fine. Any ideas why the query won't work with the reference to the text box on...

Embed Date/Time on existing Video File
I am creating a number of video files that have come from IP Cameras. I need to be able to embed the Date/Time into the file, so that when it plays, you see the current date/time appearing on the screen. I know the start time of the file. I was just wondering if anyone knew how to do this, either directly in VB, or if there is an ActiveX component around to do this. This has to be an automated process, rather than by hand. Thanks -Jerry Not sure if still current but I saw few years (?!) ago DirectShow Editing Services which was part of DirectX and is now at : http...

How do you match one column's numbers with the 2nd column?
How do you math one column's numbers with the 2nd column? Like if you had: 1 2 2 3 3 6 4 5 6 7 ... and you wanted it sorted like so 2 2 3 3 6 6 1 4 5 7 Any idea how to do that? Thanks, Lee:confused -- lnsykalsk ----------------------------------------------------------------------- lnsykalski's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3403 View this thread: http://www.excelforum.com/showthread.php?threadid=53792 Assuming your data are in columns A and B insert a staging column before column B, with following formu...

2000 File Export Issue
Running Outlook 2000 (9.0.0.2711) and trying to export a date range to Excel. I'm following the instructions, but all I get are the column headings -- no data. What am I doing wrong? ...

Deliver new email to pst file
If I change the location new email is delivered to by following the instructions below, will this work if outlook is closed? On the Tools menu, click E-mail Accounts. Click View or change existing e-mail accounts, and then click Next. In the Deliver new e-mail to the following location list, select where you want to the new messages delivered. Click Finish. Yes, the new mail will be delivered to the location you specify the next = time Outlook is opened and polls for mail. --=81 Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited ma...

Transfering XLM files between computers....
Hy!! Can someone tell me please how to do this type of work done by using C#...... Sorry, XML files,not XLM.... My mistake.... "Pilence" <ddinjar@gmail.com> wrote in message news:e4k342$pre$1@news2.carnet.hr... > Hy!! > > Can someone tell me please how to do this type of work done by using > C#...... > Pilence wrote: > Can someone tell me please how to do this type of work done by using > C#...... An Xml file is not different from other files in the file system or on the network so you can use tools like FTP to transfer files. Your requ...

Excel 2007: get formula from charttitle
I have been using this code to get a formula from a charttitle: oChart.Activate sTitle = ExecuteExcel4Macro("GET.FORMULA(""Title"")") It no longer works in excel 2007. Can someone tell me how to get a formula from a charttitle using VBA? Thanks b This sounds so familiar. I believe I've reported this as a bug. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ <be_675@hotmail.com> wrote in message news:95e87c55-280b-42b1-8415-6c2cd0d0a8a2@v17g2000hsa.goog...

Print multiple on one page
I have a small table that I need several "wallet size" copies of. Short of copying the table multiple times, how can I print several at a time on one sheet? tcebob If a one-off project you can make multiple copies as you suggest. If I were doing this with different tables over time I would use the facilities of Word's mailmerge to create custom sized labels.........6 to a page or similar. Assuming you are using Word for the mailmerge and Excel for the source see these sites for help. http://www.mvps.org/dmcritchie/excel/mailmerg.htm http://www.mvps.org/word/FAQs/MailMe...

File Download Error
We recently had to do a database reattachment and subsequent new CRM 4.0 install for a customer who experienced a virus attack. Everything is stable and working but whenever we try to hit one of the Notes>>File attachment - we get a File Download Error and it won't find the link to the original document. We can't attach new files either. Anybody see this before? ...

Pivot table add one column
How can I add one column in pivot table? When I added a column of Average 100, pivot table created 3 more columns for the first 3 columns( and I don't like it) My data Book Label Price Average A Hard paper 200 100 B Soft 100 100 C Hard paper 200 100 F Plastic 50 100 K Soft 100 100 L Plastic 50 100 M Hard paper 200 100 K soft 100 100 R Soft 100 100 T Plastic 50 100 ------------------------------------------------------------------------------------------- My pivot ...

Money 2005
I have 3 checking accounts enabled for online banking at my bank. Suddenly for 2 of the accounts when I click on "make a one-time payment or transfer" it no longer shows the options "make an electronic payment" and "show online transactions". I have successfully paid bills from these accounts previously. The bank says all 3 are setup properly. Any ideas? Thanks, -- Mike ...

Money 98 from the Works installation CD
I have upgraded to Windows 7, I backed up my Money 98 to my external HD. I now cannot reload my Money 98 program from the Works CD as it states their is a compatibility issue. Anyone have a solution for this other than getting a newer version of Money? RobertV" <RobertV@discussions.microsoft.com> wrote in message news:B9B0B30C-BDDC-4EBA-A974-CD80EBCD4B7A@microsoft.com... > I have upgraded to Windows 7, I backed up my Money 98 to my external HD. I > now cannot reload my Money 98 program from the Works CD as it states their > is > a compatibility issue. Anyo...

Publisher 07 default files
Good morning. I have a question about setting defaults and I hope someone can help me. I have a user who would like to set her default file open to a certain location; has anyone set this up for Publisher 2007? Thank you in advance -- Diane Publisher 07 does not have this default as an option. You can create a Publisher folder, add to "My Places", when you save a Publisher document the folder will be one click away. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Diane" <Diane@discussions.microsoft.com> ...

CRM outlook views arent working
Im betaing the CRM 1.2 software. All has installed fully ok up until now, I have installed a laptop which doesnt appear to be running the Outlook client right. Everything so far has been very straightforward but Im having a problem with a laptop setup to get the Outlook Sales Client installed. It has installed (after manually installing dotnetfx latest download). I have ran the English client beta on the laptop which isntalled ok - its a 256Mb ram laptop, P550 with Windows XP SP1, Office 2003 freshly installed on NTFS newly formatted partition. Im getting a screen layout which is all screwe...

Saving files with macros
I use to be able to set the protection properties to enable macros and everything with macros would work without halting. Now in 2007 I must save in ..xlsm format for this to happen. I am the only person on my computer and it's real pain to remember to file as a special format when I have created macros. Is there way to just allow macros period? -- Skip Using Office 2003 Pro 2007 Student version There is a setting in Office | Excel Options that saves all files as macro-enabled best wishes -- Bernard V Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme remove caps from emai...

.msi File Editing
I aplogize for posting this message here. I did not know where else to post it. If there is a more appropriate newsgroup, please point me to it. I have a .msi file created for installing Autodesk Architectural Desktop 2006 from an administrative image. This file was created when a prior server was in use. The new server has a different name and now the pathing contained within the file is no longer valid. The folder structure on the new server is the same, only the server name in the pathing needs to be changed. I would like to know how to edit the .msi file to change the serv...

how can I get matching to work? (M06)
All of my accounts sync online After it syncs, how do I match up the payments from my checking account which are credit card payments with the transactions in the various credit card accounts that are those payments? I have read through the help and just keep going in circles. If I change the category for a credit card payment to the credit card account, it just creates a new transaction in the credit card account. It seems to me that there should be a way to get these payments to match up automatically, and if not automatically there definitely should be a way for me to match them up ...

Set default working directory in Publisher 2007
How do you set the default working directory in publisher 2007? The "2003" way does exist anymore... File, save as, browse to your working directory, right-click the save-in column, insert the working directory. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "evaughen" <evaughen@discussions.microsoft.com> wrote in message news:36FB3C7E-14AD-4923-923C-82E644CC65D0@microsoft.com... > How do you set the default working directory in publisher 2007? > > The "2003" way does exist anymore... ...