Validating FTP File Download in OpsMgr Using PowerShell

I had a request from someone the other day for a quick sample script to verify a file could be downloaded from a  remote FTP site. I wanted to put something together that used proper .NET methods rather than scraping command line output, as this would make detection of status code more accurate (IMHO). While I was on a Live Meeting the other day, I grabbed a copy of an C# MSDN sample converted to PowerShell by MVP Thomas Lee (available on his blog). I did a quick extension of Thomas’ script to function as a two state monitor in OpsMgr 2007 R2.

Implementation Instructions

You won’t be able to implement this script in the Operations console…you’ll need to use the Authoring console to do it right. Tutorial for setting up this type of script in a two-state monitor using the PowerShell modules in OpsMgr 2007 R2 is available at

Sample Script

Here’s a sample script for use in a two-state monitor. Basically it connects to the FTP  site using the path you provide (subdirectories within site okay as well) and checks the status code returned was 226. Notice you need to provide file name in the path. It also works for authenticated FTP sites. If you want to check a site that allows anonymous access, just pass ‘anonymous’ as the username and an e-mail address as the password.

Note: This one could use some error handling for connection failures (to ensure the workflow doesn’t unload), but it’s a start.

Tip: Make sure to read the comments in the script and script headers. This should provide all the guidance you need for configuration and testing.


You can download a well-commented version of the script in the following download. FTP Site File Download Check (for 2-state monitor in OpsMgr 2007)

More PowerShell Resources for System Center

We have a growing collection of PowerShell samples for System Center and general administration. You can find them in the Downloads section and many on this page – PowerShell Scripts for System Center (Master Collection)

Follow System Center Central (via Twitter and RSS)

Twitter_icon rss_big_default_300x300

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.