locked
Get all Jobs with PowerShell or command prompt RRS feed

  • Question

  • Hello,

    I want to inventory a lot of servers, so i am writing a script for this.

    Powershell or command prompt command to get a list of all scheduled jobs to a txt file or scv.

    Is this possible?

    Monday, September 23, 2013 12:03 PM

Answers

  • [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
    
    $instance = '(local)'
    $srv = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $instance
    $jobs = $srv.JobServer.Jobs
    $jobs | Export-Csv C:\Temp\jobs.txt
    $jobs | Export-Clixml C:\Temp\jobs.xml

    • Proposed as answer by SaravanaC Thursday, September 26, 2013 10:12 AM
    • Marked as answer by Sethu Srinivasan Thursday, September 26, 2013 3:59 PM
    Thursday, September 26, 2013 10:09 AM

All replies

  • E.g. like this?
    Monday, September 23, 2013 12:50 PM
  • No, this is a script to get the Windows Server tasks. I need it to get the SQL Server tasks. It is hosted on a datacenter server.
    Monday, September 23, 2013 1:59 PM
    • Proposed as answer by Candy_Zhou Wednesday, September 25, 2013 6:01 AM
    Monday, September 23, 2013 3:20 PM
  • Thats more like it, however. I want to export it to a file. Not that it opens excel and then puts the output on the sheet. Servers don't have excel......
    Tuesday, September 24, 2013 6:44 AM
    • Proposed as answer by Candy_Zhou Wednesday, September 25, 2013 6:01 AM
    Tuesday, September 24, 2013 11:35 AM
  • Can you make an example? I tried to get the excel lines out of the example but then it doesn't work anymore.
    Thursday, September 26, 2013 6:36 AM
  • [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
    
    $instance = '(local)'
    $srv = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $instance
    $jobs = $srv.JobServer.Jobs
    $jobs | Export-Csv C:\Temp\jobs.txt
    $jobs | Export-Clixml C:\Temp\jobs.xml

    • Proposed as answer by SaravanaC Thursday, September 26, 2013 10:12 AM
    • Marked as answer by Sethu Srinivasan Thursday, September 26, 2013 3:59 PM
    Thursday, September 26, 2013 10:09 AM
  • Are you looking for a  simple powershell cmdlet that can get you this information? Can you file this as  feature request  at http://connect.microsoft.com/SQLServer/Feedback


    Thanks, Sethu Srinivasan [MSFT] SQL Server http://blogs.msdn.com/sqlagent -------------------------------------------------------------------------------- This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

    Thursday, September 26, 2013 4:01 PM