Show the status of the TFS jobs on a database server
It's a very simple use of SMO, and there's much more you could do with this, but I wanted to get a very simple example out there.
Yes, PowerShell + SMO is a great match.
PS C:\> get-tfsdbjobs tkbgitvstfdt01 | ft -a
Name CurrentRunStatus LastRunDate
---- ---------------- -----------
TFS WorkitemTracking Full Text Crawl Job Idle 8/29/2006 12:10:00 PM
TfsActivityLogging Administration Job Idle 8/29/2006 12:00:00 AM
TfsIntegration Maintenance Job Idle 8/27/2006 12:00:00 AM
TFSVersionControl Administration Job Idle 8/29/2006 12:00:00 AM
TfsWorkItemTracking Process Identities Job Idle 8/29/2006 12:10:00 PM
param (
[string] $serverName = $(throw 'serverName param is a required parameter'),
[string] $matchString = 'TFS'
)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
$server = new-object "Microsoft.SqlServer.Management.Smo.Server" $serverName
$server.JobServer.Jobs | ?{ $_.Name -match $matchString } | select Name,CurrentRunStatus,LastRunDate
get-tfsdbjobs.ps1
- Anonymous
August 29, 2006
I didn't pay much attention to Windows PowerShell when it was known by its codename,  Monad. Shortly...
- Anonymous
September 01, 2006
Buck Hodges on Team Build blogger: Aaron Halberg.
And speaking of Aaron Halberg, here is his post...