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 job, it will not work because JobName+CategoryID combination might not be unique on all servers
This issue is due to the fact that JobsCollection in SMO has JobName + CategoryID as composite unique key. We have the same constraint in sysjobs table in msdb too. JobID is unique key. You could use JobID to query a specific job. But JobID may not be same on all servers that have jobs created with same name.
Workaround for this problem is to do the following
1) Enumerate SMO JobsCollection and filter jobs by given Name
2) for each result from #1, get specific JobID
3) use JobServer SMO object’s GetJobByID() method to get the corresponding SMO job instance
4) use the retrieved SMO Job instance in #3 to Start a job
This posting is provided “AS IS” with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm