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

Comments (9)
  1. JesseH says:

    Boris, nice work here!  Through consistent small efforts you’re really building a nice archive of information and spreading the knowledge.  

    Your efforts are appreciated!

    -Jess

  2. zied says:

    hello,

    Thank you for script, it´s Nice…

    But, when i launch the command, get:

    "Health Service with the specified name was not found"…Why??

    Can you help me please to resolve this problem?!

    Thank you very much BORIS…and Good Job..

    Ciao ciao

    Zied

  3. Stephen Baron says:

    I changed AuthenticationName in the criteria to DisplayName and the script seems to work now

  4. Zied says:

    hello,

    Thanks for the Script…

    I have a question: This script is just for a computer (ComputerFQDN), and when i like to add a  Group, or more than one machine! what can i do??

    Thank you very much…

    ciao ciao

  5. Check out Boris Yanushpolsky's blog ( http://blogs.msdn.com/boris_yanushpolsky ). Boris is an SCOM

  6. Samir Dangol says:

    It only works between RunAs Account and HealthService Association. What if I want to add association like "Alert Notification Subscription Server" or "Notification Subscription Server" which are not HealthService?

  7. borisyan says:

    A runas account can only be associated with a health service.

  8. Samir Dangol says:

    If we are using SCOM UI, then we can easily add any MonitoringClass other than health service to associate with runas account.

    From UI, I am adding "Alert Notification Subscription Server" class associated with my runas account to "Notification Account" runas profile. So, I want to automate this process. How can we acheive it from cmdlets???

Comments are closed.

Skip to main content