I am using the Get-ACEData cmdlet to extract data from a simple ACCESS database.
Gate-ACEData -Filepath DBName -Table Table1 -Query 'Select LName,FName,DOB from Table1' | ??? I am lost !!!
I suppose (perhaps incorrectly) that when the Get-ACEData statement is executed, it generates into the pipeline some object of type DATASET (is this = type ACCESS database?). I would like to transform it into a simple CSV file for subsequenet processing.
But I cannot seem to get Export-CSV, ConvertTo-CSV, etc. cmdlets to work. I must be missing something. Or perhaps there is some function somewhere that can do the job. Does such a cmdlet/function exist, or do I have to "go lower" and resort to using ADO.Net to manipulate the ACCESS DB with additional PS code?
Would be grateful for any hints, tips or advice.
Datasets are a .NET object. This code assumes you've worked with datasets before. There can be multiple tables, but you are querying a single table. I have not tested the code, but hopefully this points you in the correct decision:
$query = Get-ACEData -Filepath .\mydatabase.mdb -Table Table1 -Query 'Select LName,FName,DOB from Table1' #Get results from the first table $query.Tables
Once you confirm you see the expected results, you need to understand that most Export commands expect that you are piping a PSObject. Select-Object will convert data into a PSObject. Try something like this:
$query.Tables | Select LName,FName,DOB | Export-CSV -Path "C:\Scripts\MyCSV.csv" -NoTypeInformation
Fantastic, this is very useful.
You must be logged in to reply to this topic.