check for file content in different paths out of a textfile

hi there

sorry guys..for you this might be a simple question. but i am new to 
powershell and i am queued to following problem:

1: i have a text file (array.txt), which is automatically generated. the 
content of this file are 5 lines. each line points as unc path to a location. 
how can i automatically check in each unc path of this file if there are 
files in the folder? i tried to use an array and also a foreach solution but 
i cant find the way to it. 

2: the above mentioned text file has (after the automatic generation of it) 
several blank lines. how i can prevent the creation of these blank lines?

here some code:

Get-Content 
\\server\share$\Helpdesk\Scripte\Profilbereinigung\adcomputer.txt | 
select-string -pattern $computer | ForEach-Object {Out-File -filepath 
c:\temp\array.txt -append -inputobject $_}

I really hope you understand my question :-)

Thanks for your help, guys!
0
Utf
6/10/2010 1:34:35 PM
windows.powershell 690 articles. 0 followers. Follow

2 Replies
902 Views

Similar Articles

[PageSpeed] 51

Try this to create array.txt without blank lines:
Get-Content 
\\server\share$\Helpdesk\Scripte\Profilbereinigung\adcomputer.txt | 
Where {$_ -match $computer } | Add-Content c:\temp\array.txt

This should work on the array file to check the paths:
Get-content array-txt | foreach { if (@(get-childitem $_) -gt 0) {"Files 
exist at $_"} else {"No files at $_"}}

-paul


"dumbo" wrote:

> hi there
> 
> sorry guys..for you this might be a simple question. but i am new to 
> powershell and i am queued to following problem:
> 
> 1: i have a text file (array.txt), which is automatically generated. the 
> content of this file are 5 lines. each line points as unc path to a location. 
> how can i automatically check in each unc path of this file if there are 
> files in the folder? i tried to use an array and also a foreach solution but 
> i cant find the way to it. 
> 
> 2: the above mentioned text file has (after the automatic generation of it) 
> several blank lines. how i can prevent the creation of these blank lines?
> 
> here some code:
> 
> Get-Content 
> \\server\share$\Helpdesk\Scripte\Profilbereinigung\adcomputer.txt | 
> select-string -pattern $computer | ForEach-Object {Out-File -filepath 
> c:\temp\array.txt -append -inputobject $_}
> 
> I really hope you understand my question :-)
> 
> Thanks for your help, guys!
0
Utf
6/10/2010 3:59:11 PM
Thanks
The hint for the blanklines was working fine
With the array i got an error because the script was not able to handle the 
"-gt 0" so i did with -match "":

$TArray = Get-Content "c:\temp\array.txt"
foreach ($_ in $TArray) {if(Get-ChildItem $_ | where {$_.Extension -match 
""}) {Add-Content c:\temp\result.txt "OK $_"} else {Add-Content 
c:\temp\result.txt "Fehler $_"}}

This is working very fine now, thanks for your help Paul!

"PaulChavez" wrote:

> Try this to create array.txt without blank lines:
> Get-Content 
> \\server\share$\Helpdesk\Scripte\Profilbereinigung\adcomputer.txt | 
> Where {$_ -match $computer } | Add-Content c:\temp\array.txt
> 
> This should work on the array file to check the paths:
> Get-content array-txt | foreach { if (@(get-childitem $_) -gt 0) {"Files 
> exist at $_"} else {"No files at $_"}}
> 
> -paul
> 
> 
> "dumbo" wrote:
> 
> > hi there
> > 
> > sorry guys..for you this might be a simple question. but i am new to 
> > powershell and i am queued to following problem:
> > 
> > 1: i have a text file (array.txt), which is automatically generated. the 
> > content of this file are 5 lines. each line points as unc path to a location. 
> > how can i automatically check in each unc path of this file if there are 
> > files in the folder? i tried to use an array and also a foreach solution but 
> > i cant find the way to it. 
> > 
> > 2: the above mentioned text file has (after the automatic generation of it) 
> > several blank lines. how i can prevent the creation of these blank lines?
> > 
> > here some code:
> > 
> > Get-Content 
> > \\server\share$\Helpdesk\Scripte\Profilbereinigung\adcomputer.txt | 
> > select-string -pattern $computer | ForEach-Object {Out-File -filepath 
> > c:\temp\array.txt -append -inputobject $_}
> > 
> > I really hope you understand my question :-)
> > 
> > Thanks for your help, guys!
0
Utf
6/15/2010 10:53:32 AM
Reply:

Similar Artilces:

merge MSN Bill Pay & Checking Acct
I want to merge my checking account with MSN Bill Pay but only see that I can merge MSN Bill Pay with my checking account (i.e., you lose all of your checking account information). Does any one have any suggestions? -- cheers, Tom G ...

Authorizing checks with RMS
I recently removed PCCharge and setup my syetm to work with a preferred merchant provider to allow native processing of credit & debit cards. Since check verification/authorization was handled by PCCharge to Telecheck, check authorization is now not being done. How is check authorization accomplished using a preferred provider? Thanks, Richard Unfortunately, it's not. PC Charge is the only option for check processing in RMS as far as I know. TPI or some other vendor may support it through an add-in, but RMS as shipped has no way of doing both checks and debit... -- -- Gle...

How can I delete PART of a .wmv file?
I have recorded an interview. Unfortunately, I didn't properly turn the recording off and I captured an additional 3 hours of my daily life that I don't want to archive with this recording. How can I do that? You need an audio editor A nice piece of freeware like http://audacity.sourceforge.net/ will do -- http://thewelltemperedcomputer.com "kenyadee" wrote: > I have recorded an interview. Unfortunately, I didn't properly turn the > recording off and I captured an additional 3 hours of my daily life that I > don't want to archive ...

Check names not working for multiple address books / contacts
Hello! I have upgraded from outlook 2003 to outlook 2007, my contacts are stored in pst. I used to be able to search for a name via check names and it displayed me all the results from global address list and from my contacts, but now it only does one. It does not matter which one I set in the checking order, whichever is top will be the one that provides the result. I would like it to show me both results, how would I go about to set that up? Thank you Deana More accurate and complete information would be helpful. The Global Address List is only available to those who c...

populate Keywords with a batch file?
I'd like to know how to create a batch file that can store a key word (including a trailing comma). I'd open an appropriate word.doc, run the batch file, and that keyword and comma would be inserted in the Keywords panel, either preceding any existing keywords there, or appended to any existing keywords there. So if I had multiple batch files, each embedded with their own unique keyword and comma, I could invoke certain ones as desired, one after another, progressively populating my document's keywords panel with multiple keywords all strung together with comma d...

How do I create Check list
1.I am new to excel and want to create a simple check list. I would like to have the first column check boxes and then the following columns discription and notes. Can someone give me a step by step on how to do this. I have created spread sheets but am not familiar with check boxes. 2.Also, Can someone tell me the difference between Access and Excel? Geek 1) Not sure what you're aiming to do with the checkboxes, but if you right click on the toolbar area, you will get a list of available toolbars. You want either the 'forms' toolbox or the 'controls' toolbox. Genera...

I cannot open Word files for no apparent reason
I can't open files that I've used frequently, recently...then I can't close the blue window! I have to End Task. Possibly it may be the problem below. However, if this doesn't work, please let us know the version of Word and Windows and are they patched fully up to date? Also, are you able to open Word but not the documents? Details were sadly lacking in your post. That's a symptom of a Word Data Key corruption - usually because Word has been running when updates are installed. Run Regedit and expand by double-clicking to the key below. With DATA selecte...

file extensions .msg
I have received several messageswith attachments with a files extension of .msg and can not open them. How do you open these attachments. I understand that if you save them you can change the extension and open them in another program, but i have not been able to do this. Outlook can open them - if you're using Outlook Express, you won't be able to see them. Ask the sender to put the message in the body of the message, not send it as an attachment. Bob wrote: > I have received several messageswith attachments with a > files extension of .msg and can not open them. How d...

printing 1200dpi files
Hello, I am using the trial version of Publisher 2007. I like it a lot. But a problem has surfaced. When I tried to print or print-preview pages that have 1200 dpi bitmaps on them, the images with either not display, not print or both. If I reload those same images as 600dpi files, the problem goes away. Everything was working fine for a while. But once I launched the file from My Documents rather than opening Publisher and then opening the file. Ever since then I've had this problem. Sometimes the 1200 dpis will print, sometimes not. I can have a 60 page file with lot...

Check text field value against underlying table or query of combo box
Hello, I have a form on which the user can enter new records or update existing ones. If the user enters a new record on the form, I would like to have an 'After Update' event on one of the text fields, which is the item# to check if the value entered already exists in the underlying table, tbl_item. How can I call the table from the 'After Update' event of the text field and check for that value in the table? Thanks in advance. Regards, A. Crawford antcraw@swbell.net wrote: >I have a form on which the user can enter new records or update >existing ones. >If the us...

setting a dedicated place to open an "xls" file
Gentlemen, I do work at the office evey day on spread sheets and save to a disk, which I bring home. Is there any way that I can "lock in" a dedicated point to retrieve my files once I have saved them to "c:\documents & Settings\my documents. When I click "Open and go to "A" drive to get the file from the disk that I took home, my computer "remembers" that this was the last place I opened a file from. And when I am in Excel and want to open a file, the computer looks in "a". Thanks Raymond Tools / Options / General Tab - Default File loc...

Linking Chart items to files
Anyone got a clue on how to link each stacked bar(or similar) to a different file, so when someone views the file, he can click on the bar, to get a relevant document on his web-browser/similar(pdf, whatever). Any suggestions? You can write event procedures that determine which point was clicked. Within the procedure you need some kind of lookup to see what document should be launched according to the point which was clicked. Here's an article on chart events: http://www.computorcompanion.com/LPMArticle.asp?ID=221 - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical...

Preventing multiple check boxes from being checked
I have a worksheet with over 20 rows of check boxes with 5 check boxes in each row. (from the forms toolbox) I would like to prevent the user from checking more than one box in each row. Is this possible? BTW, this forum has been a great help. I'm so glad that expert Excel users are so willing to share their wealth of knowledge. Thanks again. Jae Put them in a group box, again from the forms toolbar. Drag the group box onto the sheet, then drag the checkboxes in. -- HTH RP (remove nothere from the email address if mailing direct) "Jae" <Jae@discussions.micro...

ShellExecute() multiple files to open to one instance
I am opening DWG files to AutoDesks TrueView. When i loop to open these files, a new instance is created for each file i open. Is there a way to create a process and send files to it only? Or a registry key in windows i can set to not allow multiple instances of this program? My goal is to open multiples files to one instance of this viewer, it can handle many files at once. Thanks! check if the program has any command line switch or automation interface to reuse an existing instance. -- Regards Sheng Jiang Microsoft Most Valuable Professional in Visual C++ http://www.jiangsheng.net ...

File Path on a report
I want to put the path details of the Access file from which a report was run into the footer of a report. Is this possible and if so how? You can just write those in the footer and it should print on each page of the report. Use the Label command to write it in. "John.bb" wrote: > I want to put the path details of the Access file from which a report was run > into the footer of a report. Is this possible and if so how? If your database is not split then just add a control to your report and set its control source to =CurrentDb().Name If you database is split into a f...

Printing Checks
I'm having a problem printing checks from Money 2003. I have three accounts that come up in one .mny file. Two of the accounts use 3-on-a-page checks and I want the name and address printed on them. One account uses voucher checks and needs to be nudged a little south. When I go to print checks I have to be aware of what account I'm in and change the settings by hand to make sure the checks print correctly. How can I make the check-print settings stick with the account I'm using. It's a pain to have to remember every time. I'm frequently forgetting and screwing up a pag...

offline files
My laptop is set up to connect with the company lan at work. When I take the laptop home, some of my email files are available and some are not. This is aggravating when I'm at a meeting and expect to find the email with the previous minutes, but can't. What can I do? Check your sync settings while online, and make sure it's set to sync *all* the folders you want - and to do so automatically while online every X minutes, and automatically when you close Outlook. Note - non-default folders will need to be setup for offline use manually, and new subfolders will not inherit thos...

how to write and save ini files like some apps do with their ini's
Im working on app that will keep lists of things in a ini file from edit boxes on a dialogs. I already know about CEdit and WritePrivateProfileStrings things. but I need things to be listed like this. also I will add ability to delete. mIRC does this same way with the servers.ini and alias.ini [thing] n0=here n1=food n2=metal n3=hotdogs n4=metals n5=pencils n6=pens n7=paint for your info. Im using MFC to make my program in Visual C++ 6.0. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,...

Employee Check Format-Graphical
Does anyone know of a TK that shows how to convert one of the employee check from a text report to a graphical report? We do not have Direct deposit, I looked in the Report Downloads from Great Plains and did not see one there either. thanks -- Doug There's no secret here. Just un-check the "Text Report" option in the Report Definition window. And then modify the report so it looks like you want it. This will take some time. The reports don't transfer from text to graphical nicely. "Doug" wrote: > Does anyone know of a TK that shows how to convert...

Can't save file in network or hard disk
Receive new xp last week and running excel 2000. The file has 12 tabs and lots of data linking between tabs. Sporadically, I cannot save the file back on the network, cannot save under another name, and cannot even save on the c:drive. The message is "xxx.xls cannot be accessed. The file may be read only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding". The network is not down and I am not disconnected from the network. I do not encounter this problem with the old nt. Other files have less tabs and less c...

Check Names = "Exchange Server computer is busy..."
Here's what I got: Active Directory on Server 2003 1 Domain Controller also running DNS and WINS No other DNS or WINS servers (I know, I know) Static IP Addresses...NO DHCP Exchange Server 2003 on a member server Client running W2K SP4 Outlook 2000 SP3 Exchange has 4 mailboxes set, but nobody is using it. I'm still testing things out. When I try to connect to Exchange via my Outlook 2000, I get the following message: "The function cannot be performed because the Microsoft Exchange Server computer is busy. Try again later" I've tried it from 3 different client comp...

Comparing Excel Files
Does anyone know about a Macro or Add-in that compares 2 Excel files/sheets in a similar manner to Compare in Word? Thanks. --- Message posted from http://www.ExcelForum.com/ Amr Tabbarah < wrote: > Does anyone know about a Macro or Add-in that compares 2 Excel > files/sheets in a similar manner to Compare in Word? One way is to save two sheets as CSV files and use Word to compare the CSV files. (It's awkward, but it gets the job done.) 1. One method I like is to make a third sheet to show differences an put a formula like this in all cells :- =Sheet1!A1-Sheet2!A1 ....for...

Printing MICR checks
Hello, We are having an issue printing checks on the Select Payables Checks window. When we try to print the checks we receive the error message below: "Warning: You have MICR but are not in a MICR screen. To use MICR, abort this screen and set up security access." The user has access to this screen but I'm not sure what this error message means. There was nothing related to this in the Knowledge Base either. Has anyone else received this error message before and if so how did/do you resolve it? Thanks! The user has the third party mekorma check writing module ...

File name list in the open dialog box.
In the open dialog box, how to delete the list of files appearing in the file name drag down menu in excel 2007? Not sure where you are finding this list. Do you mean the Recent Documents you see when you click on the Button? You can clear that by setting your MRU list to 0 under Button>Excel Options>Advanced>Display. If you mean the list you see when you go to Button>Open then you will have to set a new default file path to a folder that is empty. Gord Dibben MS Excel MVP On Thu, 4 Mar 2010 09:10:01 -0800, Acs <Acs@discussions.microsoft.com> wrote: ...

Check off boxes
Publisher 2003 in use. I am creating a questionnaire that will be included in a newsletter. I am using the publisher software to make this form. Somewhere, in the past, I saw a keyboard shortcut to inset checkoff boxes, however, I cannot remember the key strokes. Any help along this line will be greatly appreciated. Thank you and enjoy your day. Mike Mike Reshetar wrote: > Somewhere, in the past, I saw a keyboard shortcut to inset checkoff boxes, > however, I cannot remember the key strokes. Use Wingdings and the � or q characters. -- Ed Bennett - MVP Microsoft Publisher h...