Need help to script out multiple SQL Jobs listed in an XMl file
Hello Everyone, This is kind of urgent for me and I need your help in this regard. I need to script out SQL jobs which are listed in an XML file for a SQL instance. I did go through the articles and forums for the script and found some links for me to atleast get started but I am totally new SQL Server SMO programming and I dont know how and what changes to make in the script listed in the link below:
http://www.johnsansom.com/script-sql-server-agent-jobs-using-powershell/ I don't need a solution through SSMS since the name of jobs could be different everytime in the XML file. Please help me guys!!! Thanks Devesh
Does it have to be an XML file? I'm sure an XML file can be processed in PowerShell but it would be easier if the thing that produces an XML file could just list the job names in a text file and then you could use the same pattern John uses to enumerate servers.
I'm afraid I don't know enough PowerShell to help you change it but the idea would be to connect to the server once and then loop through the file, finding each job in the Jobs collection and scripting it out. It still seems like your requirements are a little odd though. You could just put the one server name in the servers file and use John's code as it is. The only difference would be that you would have all the jobs scripted out instead of just some of them. Does it matter if more than just the listed jobs are in the output? (Just a thought.)