How to output a powershell into a sql server 2008 table

Last post 12-22-2008, 12:54 PM by Robyn Page. 1 replies.
Sort Posts: Previous Next
  •  10-09-2008, 9:03 AM Post number 69957

    How to output a powershell into a sql server 2008 table

    Hy all, my english is very bad so i try to explain

    I get this script in here (RON DAMERON article - http://www.simple-talk.com/sql/database-administration/why-this-sql-server-dba-is-learning-powershell/) and works perfectly

    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") |
    out-null
    foreach ($svr in get-content "C:\AllServers.txt")
    {
       write-host $svr
       $srv=New-Object "Microsoft.SqlServer.Management.Smo.Server" "$svr"
       $srv.jobserver.jobs | where-object {$_.lastrunoutcome -eq "Failed" -and
    $_.isenabled -eq $TRUE} | format-table name,lastrunoutcome,lastrundate
    -autosize
    }

    It´s list all sql server agent jobs with error in my servers. Ok

    I want to know how a output this into (using this script) a sql server 2008
    table and some kind of file (csv..txt)

    Thanks a LOT

     

  •  12-22-2008, 12:54 PM Post number 70968 in reply to post number 69957

    • Robyn Page is not online. Last active: 07-01-2009, 3:07 AM Robyn Page
    • Top 50 Contributor
    • Joined on 10-19-2006
    • Chelmsford, Essex
    • Level 2: Deep Blue

    Re: How to output a powershell into a sql server 2008 table

    there is a very thin wrapper over ADO in SMO which will allow you to write the output to a table in either 2005 0r 2008.
View as RSS news feed in XML