• Are the queries you are trying to capture rows affected from selects or insert/update/delete?

    If they are modification you are trying to get affected rows for something like this may work for you.

    function Invoke-Sqlcmd2

    {

    param(

    [string]$ServerInstance,

    [string]$Database,

    [string]$Query,

    [Int32]$QueryTimeout=120

    )

    $conn=new-object System.Data.SqlClient.SQLConnection

    $conn.ConnectionString="Server={0};Database={1};Integrated Security=True" -f $ServerInstance,$Database

    $conn.Open()

    $cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn)

    $cmd.CommandTimeout=$QueryTimeout

    $cmd.executenonquery()

    $conn.Close()

    }

    Invoke-Sqlcmd2 -ServerInstance "instancename" -database "dbname" -Query "update foo set id = 0 where id < 100"

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]