Author Posts

February 4, 2017 at 4:01 pm

Hello all, I hope someone can help me out. This is my first PowerShell script and it works but I am having issues trying to write the output to a text file. Below is a sample of my script. When I do run the script the only output I have is the last line. I was hoping for each Select-Line statement they would all be written but I was wrong.

Here is the code.

Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.001069\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002305\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002315\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002476\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002485\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002494\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002571\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002585\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002607\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002608\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002614\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002622\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002620\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002627\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002765\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002768\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002803\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002801\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002826\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002830\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002833\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002838\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002842\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002846\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.002913\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003017\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003076\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003099\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003114\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003196\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003197\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003199\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003227\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003283\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003303\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003304\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003308\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003309\Email_Import_PDF.xml -pattern "DateSent" | Format-List
Select-String \\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.003310\Email_Import_PDF.xml -pattern "DateSent" | Format-List > C:\emailtime.txt

February 4, 2017 at 4:28 pm

You could try the following:

$path = "\\ppisi1dcs1.isilon.storage.adt.com\datacapPROD\Datacap\ADTSalesFlex\batches\20170131.*\Email_Import_PDF.xml"
Get-ChildItem -Path $path | Select-String -Pattern "DateSent" | Format-List | Out-File -FilePath C:\emailtime.txt