Share This Post

VSAE – Include File Content

One of the features I love in the Visual Studio Authoring Extensions is IncludeFileContent.  This feature enables you to include script files into a management pack, without needing to write the script with the relevant XML tags such as <ScriptBody>.

In MP development up to now, you would need to write your script in the XML of the management pack, like this:

Option Explicit


Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")

Now, with VSAE you can write your script in a VBS, PS1 or JS file just as you would outside of SCOM and then include it in the MP, like this:


To do this is very simple, just right click in your MP project and select Add -> New Item…, select Templates, and then select the relevant script type with a relevant name.

Screen Shot 2013-04-03 at 21.41.23


Once you've added your new script, you can add the contents of your script to file.

Screen Shot 2013-04-03 at 21.47.00


Once you have your script completed, you can now include it in your management pack.  In the example below I have included my new MonitoringScript.vbs file in a task using the Microsoft.Windows.ScriptProbeAction module.

Screen Shot 2013-04-03 at 21.49.23


The include syntax in this example is $IncludeFileContent/Scripts/MonitoringScript.vbs$, and this is generated based on the path of the file.  In this MP, I stored the VBS file in a folder called Scripts, which is why "Scripts/MonitoringScript.vbs" is added to "IncludeFileContent".

I think this is a great feature as you can use it wherever you need to use a script.  This means you can you store all your scripts under one folder in your project which makes them easily accessible and makes editing much safer, as now you can just simply edit the script with no risk of a typo in the XML of the MP itself.

I encourage everyone to use this feature.

Happy MP writing!

Share This Post

Leave a Reply