<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Starting Jobs in Powershell using Job Name</title><link>http://blogs.msdn.com/b/sqlagent/archive/2010/12/29/starting-jobs-in-powershell-using-job-name.aspx</link><description>When starting jobs in powershell with smo, you have to use the jobname and categoryID. If you have same job name on multiple servers that could be in different category, and if you are running a single script that connects to multiple servers and starts</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Starting Jobs in Powershell using Job Name</title><link>http://blogs.msdn.com/b/sqlagent/archive/2010/12/29/starting-jobs-in-powershell-using-job-name.aspx#10110405</link><pubDate>Thu, 30 Dec 2010 19:30:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10110405</guid><dc:creator>Chad Miller</dc:creator><description>&lt;p&gt;This also works:&lt;/p&gt;
&lt;p&gt;# Note: in SQLPS window, CD SQLSERVER:\SQL\&amp;lt;Your_server&amp;gt;\&amp;lt;Inatance_Namw&amp;gt; $jobName = &amp;#39;mytestjob&amp;#39;&lt;/p&gt;
&lt;p&gt;$jobserver = get-item JobServer&lt;/p&gt;
&lt;p&gt;($jobserver.Jobs[&amp;quot;$jobName&amp;quot;]).Start()&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10110405" width="1" height="1"&gt;</description></item><item><title>re: Starting Jobs in Powershell using Job Name</title><link>http://blogs.msdn.com/b/sqlagent/archive/2010/12/29/starting-jobs-in-powershell-using-job-name.aspx#10110036</link><pubDate>Wed, 29 Dec 2010 22:46:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10110036</guid><dc:creator>Sethu Srinivasan</dc:creator><description>&lt;p&gt;Thanks for your valuable feedback Stephen. &lt;/p&gt;
&lt;p&gt;Agree with you on delivering cmdlets for SQL agent that would simplify tasks. Could you please post your feedback and proposed suggestion at &lt;a rel="nofollow" target="_new" href="http://connect.microsoft.com"&gt;http://connect.microsoft.com&lt;/a&gt; ?. Our dev team can look at addressing this issue in future releases of SQL Server&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10110036" width="1" height="1"&gt;</description></item><item><title>re: Starting Jobs in Powershell using Job Name</title><link>http://blogs.msdn.com/b/sqlagent/archive/2010/12/29/starting-jobs-in-powershell-using-job-name.aspx#10110003</link><pubDate>Wed, 29 Dec 2010 21:11:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10110003</guid><dc:creator>Stephen Mills</dc:creator><description>&lt;p&gt;Ouch. &amp;nbsp;While this is useful to know, I would think having it default to a category of &amp;#39;%&amp;#39; and having it do a like match would be better. &amp;nbsp;It seems like SMO really has some rough edges when it comes to PowerShell. &amp;nbsp;I think MS needs to really do some usability studies involving SQL Server and PowerShell. &amp;nbsp;Right now it isn&amp;#39;t very usable, it seems like you need to make scripts for everything to get it to work as expected. &amp;nbsp;As a little example try to write a single line in PowerShell that will script all objects in a database, regardless of object type, for SQL 2005, 2008, and 2008 R2. &amp;nbsp;Since you get errors on objects categories not existing for certain versions, it&amp;#39;s a real pain, but it shouldn&amp;#39;t be. &lt;/p&gt;
&lt;p&gt;Heck, the SQL team should provide cmdlets to do all this. &amp;nbsp;Not just a simple thin layer on top of SMO. &amp;nbsp;The following is how your example would work if you had well written cmdlets:&lt;/p&gt;
&lt;p&gt;Start-SQLJob -Server &amp;#39;SQLServer&amp;#39; -JobName &amp;#39;MyTestJob&amp;#39;&lt;/p&gt;
&lt;p&gt;or to start it by jobid:&lt;/p&gt;
&lt;p&gt;Get-SQLJob -Server &amp;#39;SQLServer&amp;#39; -JobName &amp;#39;MyTestJob&amp;#39; | Start-SQLJob&lt;/p&gt;
&lt;p&gt;Just by looking at these examples, you can see what they are doing. In the second example, the Get-SQLJob would return the name of the job along with the category, Start-SQLJob pulls the Server and the JobID from the pipeline. &amp;nbsp;You don&amp;#39;t need to do any odd looking commands or scripting work arounds to get it to work.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10110003" width="1" height="1"&gt;</description></item></channel></rss>