opc.three (4/10/2013)
This might help get you started:
$Instances = (Get-Content 'C:\Instances.txt') # Make a text file containing your instances, one on each line
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
foreach ($instance in $Instances)
{
$sqlServer = New-Object "Microsoft.SqlServer.Management.Smo.Server" $Instance
$sqlAgent = $sqlServer.JobServer
if ($sqlAgent -eq $null)
{
Write-Error "Could not get SMO SQL Agent object for $Instance, permissions issue?"
}
foreach($agentJob in $sqlAgent.Jobs)
{
'Name: ' + $agentJob.Name
'CurrentRunStatus: ' + $agentJob.CurrentRunStatus
'CurrentRunStep: ' + $agentJob.CurrentRunStep
'LastRunDate: ' + $agentJob.LastRunDate
}
}
Very cool, Orlando. Good link, too! Book Marked.
--Jeff Moden
Change is inevitable... Change for the better is not.