Skip to content
Advertisement

PowerShell code to script out all SQL Server Agent jobs into a single file

I was trying to script out all the SQL Server Agent jobs for category ‘Data Warehouse’ into a single file

I was able to do it using PowerShell, where every single job creates a single file.

But I need one file for all the SQL Server Agent jobs under category ID = 100 (or Category : = ‘Data Warehouse’)

Code I’m currently using:

Advertisement

Answer

Give $FileName a single file name for the whole set. Then you can leave out the whole foreach block:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement