Specifying a run as account for a run as profile

Here is a sample script that demonstrates how to specify which RunAs account to use for a particular RunAs profile on a particular agent. The main reason I am blogging about this is that the code that needs to be written to do this is not straight forward, and one day you may need to automate this.

The script takes three parameters:

runAsProfileName - This is the name of the RunAs profile as it appears in the OpsMgr console

runAsAccountName - This is the name of the RunAs account as it appears in the OpsMgr Console. This is not the AD account name.

computerFQDN - This is the fully qualified name of the computer on which the RunAs account should be used by any rules/monitors/discoveries/tasks which are using the particular RunAs Profile.

In order to run the script you will need to do the following:

1 - Open the OpsMgr command shell

2 - Run the following: C:\SpecifyRunAsAccountForRunAsProfile.ps1 -runAsProfileName:'SQL Server Monitoring Account' -runAsAccountName:'SQL Monitoring Account' -computerFQDN:'srv1.contoso.com'

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included scripts are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

SpecifyRunAsAccountForRunAsProfile.zip