Invoke-AdoCommand -AsPSObject

Topics: Developer Forum, User Forum
Jun 3, 2010 at 6:28 PM
Edited Jun 3, 2010 at 6:42 PM

I specifically spent time learning Invoke-AdoCommand to easily pipe rows of data to later filter or output steps (easier to get data into a simple text file than SQL Management Studio).  But it looks like 'Invoke-AdoCommand -AsPSObject' doesn't work.  I can't get it to work and I can't find a working example on the web.

I would consider working on a patch to make this work if I know how -AsPSObject is supposed to work.  Is it supposed to create an PS object with note properties for each column from the IDataReader?  If you point me to a similar mapping from a custom collection to generate PSObject in the PSCX sources I'm sure I could do the same for Invoke-AdoCommand from IDataReader.

 Update: 6/3/2010 Adding Code Sample:
This uses SQL 2008 sample DB, AdventureWorks R4

$defaultConn = 'Data Source=.;Initial Catalog=AdventureWorksLT2008;Persist Security Info=True;Integrated Security=True'
$defaultSQL = 'SELECT TOP 1000 [ProductModelID], [Name], [CatalogDescription], [ModifiedDate]
  FROM [AdventureWorksLT2008].[SalesLT].[ProductModel]
  where ProductModelID < 10';
Invoke-AdoCommand  -AsPSObject:$true -ProviderName Sql -ConnectionString $defaultConn -CommandText $defaultSQL

 

Developer
Jun 3, 2010 at 8:23 PM
Hmm, this is a switch that should have been removed - sorry. You're right, it's not implemented (yet.)

On Thu, Jun 3, 2010 at 2:28 PM, yzorg <notifications@codeplex.com> wrote:

From: yzorg

I specifically spent time learning Invoke-AdoCommand to easily pipe rows of data to later filter or output steps (easier to get data into a simple text file than SQL Management Studio).  But it looks like 'Invoke-AdoCommand -AsPSObject' doesn't work.  I can't get it to work and I can't find a working example on the web.

I would consider working on a patch to make this work if I know how -AsPSObject is supposed to work.  Is it supposed to create an PS object with note properties for each column from the IDataReader?  If you point me to a similar mapping from a custom collection to generate PSObject in the PSCX sources I'm sure I could do the same for Invoke-AdoCommand from IDataReader.

 

Read the full discussion online.

To add a post to this discussion, reply to this email (Pscx@discussions.codeplex.com)

To start a new discussion for this project, email Pscx@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--

---
404 signature missing
Jun 13 at 1:37 PM
This -AsPSObject switch is still present in the Invoke-AdoCommand cmdlet in PSCX 3.1 and it still doesn't work. Is the plan to remove or to implement this?

thanks,

Jim