AddToDistList Tool - Adding a computer to the Distribution list on a RunAs Account
Some weeks ago I saw a question about how to use PowerShell for the ApproveCredentialForDistribution method. This Method Approves a secure credential for distribution to a list of MonitoringObject objects or PartialMonitoringObject objects. Calling this method adds the specified list to the already existing approved list in the system.
You use this method when you add a computer to the Run As Account.
But what if you want to add not one but much more Computers to a Distribution List? In the OpsMgr Console you need to select each computer one-by-one and add the computer to the list. Would not it be cool if we could use PowerShell or some commandtool to create a script to do it automatically for us?
On the Technet System Center Forum website there is also a discussion about this topic. So I looked at the method on MSDN and tried to get this working in PowerShell. But till now I’ve not been able to get this working in PowerShell So I created a Console App in Visual Studio 2010 which seems to work ok. I’ll add the source code so you can have a look how I created the Console App. I also used nConsoler, which helped with the parsing of arguments in the console application. And finally I used ILMerge to merge the nConsoler dll in a single .NET assembly.
Program.cs:
|
Ok let’s have a look how it works.
Scenario:
We will be adding the OpsMgr Agent OpsMgrDC01.stranger.local to the SQL MP Monitoring Account Run As Account. (yes this is just an example there is no SQL running on my Domain Controller)
Current Config SQL MP Monitoring Run As Account:
Step 1: Install AddToDistList console application on machine where OpsConsole is installed.
Just copy the AddToDistList.exe to a folder of your choice.
Step 2. Open the AddToDistList.exe from command prompt.
As you see it needs 3 parameters:
- RMS Name
- RunAs Account Name (domain account name)
- FQDN OpsMgr Agent
When we want to add the OpsMgrDC01.stranger.local OpsMgr Agent to the SQL MP Monitoring Account Run As Account we need to run the following:
AddToDistList.exe opsmgrrms.stranger.local om_sql_mon opsmgrdc01.stranger.local
Let’s check if the opsmgrdc01 agent is added to the distribution list.
Yes! It worked
Now you could create a script that pull’s the names of the computers that need to be added to the Distribution List from a text file and call’s the AddToDistList console application.
Download AddToDistList.exe
Download SourceCode
Disclamer:
This is provided as a sample, no support is implied. Provided 'AS IS' without warranty of any kind. I wrote it for me initially.I'm not a developer, and don't profess to be either; just to set your expectations
Tested on OpsMgr 2007 R2.
Comments
Anonymous
January 01, 2003
Just curious - what if you have multiple Run As accounts that use the same login?Anonymous
January 01, 2003
Hi Daniele, Good idea! Will contact you get some info on how to do this. Regards, StefanAnonymous
January 01, 2003
Maybe, rather than using the external library to parse the commands of the DOS utility, you could have built a cmdlet - that way you would have still written it with Visual Studio, but would be able to use it in Powershell. Maybe next time :-)Anonymous
May 25, 2011
Is it possible to read with a powershell the members of a group and add them all with AddToListTool to DistributedList? Thanks for any suggestions :-)Anonymous
March 29, 2012
i have a similar issue as matt does, momadmin account name in multiple domains, this would be good if i could either specify domainmomadmin or use the run as account displayname rather then the account name