How to output a powershell into a sql server 2008 table

Last post 10-09-2008, 9:03 AM by laerte. 0 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

     

View as RSS news feed in XML