/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" PowerShell Import Shares and Security info From CSV "," An other PowerShell Blog is born "," Windows PowerShell: TFM "," PowerShell Export Shares and Security info to CSV "," powershell (Monad) Home on computerperformance.co.uk "," PowerShell in Action "," PowerShell out-PropertyGrid (MSH view-Object) "," PowerShell AD site Finder "," PowerShell and SMS 2003 "," Upgrading MSH, My first Windows PowerShell Commands "," ")

Thursday, May 04, 2006

 


PowerShell How Can I Query a Text File and Retrieve Records That Occurred on a Specific Date?



When I did see todays Hey, Scripting Guy! question (and more answer)

Hey, Scripting Guy!
How Can I Query a Text File and Retrieve Records That Occurred on a Specific Date?

I could not resist :

Hey, PowerShelled Scripting Guy!

import-csv employees.txt |? {$_.HireDate -eq '3/1/2006'}

but to be honest I also use ADO a lot with CSV files from PowerShell, but mostly with a Dataset and a DataAdapter,

# with import-csv function

MowPS>import-csv employees.txt |? {$_.HireDate -eq '3/1/2006'}

LastName               FirstName              Department            HireDate
--------               ---------              ----------            --------
Myer                   Ken                    Finance               3/1/2006
Ackerman               Pilar                  Finance               3/1/2006

# With ADO (and 2 helper functions)

MowPS>. connect-csv (pwd)

TABLE_NAME
----------
Employees#txt

MowPS>(get-DataTable "Employees#txt") |? {$_.HireDate -eq '3/1/2006'}

LastName               FirstName              Department            HireDate
--------               ---------              ----------            --------
Myer                   Ken                    Finance               3/1/2006 12:00:00 AM
Ackerman               Pilar                  Finance               3/1/2006 12:00:00 AM



in this case you see that it does not matter much, and for the ADO example I need 2 helper functions and it is outputting more or less doing the same, but in the second example I have the power of the .NET dataset and can make relations etc

for more info and the helper functions see :

working with CSV files in MSH (part one)

working with CSV files in MSH (part two)

And without the dataAdapter and dataset :

more Monad scripts, and a bit more CSV

enjoy,

gr /\/\o\/\/
Tags :


Comments: Post a Comment



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?