Posts
23
Comments
229
Trackbacks
0
SCOM: Bulk Enable ACS for a Group

I've seen a few scripts out there on bulk-enabling ACS for just one group of servers in SCOM (OpsMgr 2007.) but nothing seemed to work.

So, I decided to learn powershell so that I could write a better script to do this. Here is what I came up with. About a third of the script is comments that should help you understand

exactly what the script is doing. That way you can have a bit of confidence when running it. Also, if you read the script and the comments a few time hopefully things will start to click

in your mind and you will start to get a better understanding of powershell and SCOM.

 

To use the script type the script name followed by the FQDN of the RMS the FQDN of the ACS collector, and the display name of the group you want to affect.

Example: acsGroupEnable.ps1 RMS1.yourdomain.int ACS1.yourdomain.int 'your group name'  -yes single quotes. Maybe double quotes work too, but I'm too scared to try. ;-)

 

Here's the script:

 

param ($rmsServerName,$collectorServerName,$groupName)
#To list all groups by displayName connect to root of management server
#via powershell and run: get-childitem | format-list -property displayname

#Connect to RMS using FQDN

#add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" #Use this if you aren't on the SCOM Powershell Console.
set-location "OperationsManagerMonitoring::"
new-managementGroupConnection -ConnectionString:$rmsServerName;
set-location $rmsServerName

#Create Health Service Class Instance for later use.
$healthServiceClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthService

#Create a task that enables ACS when invoked
$enableAcsTask = get-task -path \ | where {$_.Name -eq 'Microsoft.SystemCenter.EnableAuditCollectionService'}

#Create override for ACS
$overrides = new-object Hashtable
$overrides.Add("CollectorServer",$collectorServerName)

#Use credentials only if you need to. Otherwise leave commented out.
#$credentials = Get-Credential #use this if you are not logged in with correct OpsMgr account.

#get all computer objects from the group you want to affect and put them into a collection
$colServers = Get-ChildItem (get-childItem | where {$_.displayName -eq $groupName}).PathName;

#for each computer in the collection, connect to that computer's health service object
foreach($varServer in $colServers)
   {
      $healthServices = $varServer.GetRelatedMonitoringObjects($healthServiceClass)
      foreach($hs in $healthServices) #for each server in that class (Only the one server you have connected to.)
         {
            if ($hs.isAvailable -eq $true) #if the server is currently talking to OpsMgr
               {
                  "Enabling Audit Collection for " + $hs.DisplayName;
                  #Enable ACS on the computer
                  Start-Task -task:$enableAcsTask -TargetMonitoringObject:$hs -overrides:$overrides #-credential:$credentials #uncomment the credentials if you need to use alternate credentials.
               }
            else
               {
                  "Skipping: " + $hs.DisplayName + ". This computer is disconnected from OpsMgr."
               }

            }

   }

posted on Tuesday, December 02, 2008 5:10 PM Print
Comments
Gravatar
# I Lost 30 Pounds in 30 Days
I Shed T h i r t y P o u n d s i
5/5/2009 4:23 PM
Hi, nice post. I have been wondering about this topic,so thanks for posting. I'll definitely be coming back to your blog. Keep up the good work
Gravatar
# 4IeY36, <a href="http://www.afolrwn3eo.com">rflcu</a> , [url=http://www.thshrdbbpk.com]2n2bi[/url], http://www.u8mbvmnrjw.com snuvi
ez2iup gbhyw
6/6/2009 7:08 AM
4IeY36, rflcu , [url=http://www.thshrdbbpk.com]2n2bi[/url], http://www.u8mbvmnrjw.com snuvi
Gravatar
# http://business.goodnano-av.com/
Jalsstoox
7/5/2009 5:48 AM
Read more hot reports about Business, Form business or Women small business loans http://business.goodnano-av.com/
Gravatar
# http://busty.goodnano-av.com/
bewmevyspoosy
7/9/2009 4:45 AM
Most recent information about Paris hiltons boobs and Boobs big http://busty.goodnano-av.com/
Gravatar
# http://california.goodnano-av.com/
flopsyroorp
7/16/2009 8:34 PM
Best reviews of the day about California, Berkeley apartments california, Apartments in oceanside california and California bankruptcy lawyer http://california.goodnano-av.com/
Gravatar
# http://car.goodnano-av.com
Nemsdrome
7/24/2009 10:50 AM
Best reviews of the day: Car, Car loan dallas, Car mover and Online car games http://car.goodnano-av.com
Gravatar
# http://cameltoe.goodnano-av.com/
DuexiaFluedia
8/2/2009 12:26 AM
Waiting for NEWS? Welcome! See about Cameltoe, Cartoon cameltoe, Amateur cameltoe, Cameltoe rater http://cameltoe.goodnano-av.com/
Gravatar
# pahNugNunny
Exambamollutt
9/4/2009 9:23 AM
nuturigreeHig
ydef
LiexToiceli
Bwgg
Gravatar
# 1Pq4tz <a href="http://mztyxmslpyij.com/">mztyxmslpyij</a>, [url=http://syjylpipgook.com/]syjylpipgook[/url], [link=http://mfxyrutxummd.com/]mfxyrutxummd[/link], http://liegutwgfkch.com/
xjtfaxqz
11/8/2009 7:21 AM
1Pq4tz mztyxmslpyij, [url=http://syjylpipgook.com/]syjylpipgook[/url], [link=http://mfxyrutxummd.com/]mfxyrutxummd[/link], http://liegutwgfkch.com/
Gravatar
# g32TU6 <a href="http://rsbynbzmqywz.com/">rsbynbzmqywz</a>, [url=http://pyyphgotnnfz.com/]pyyphgotnnfz[/url], [link=http://rfyvxpztwblp.com/]rfyvxpztwblp[/link], http://aytazlaycysx.com/
qezgneyuje
1/5/2010 6:02 AM
g32TU6 rsbynbzmqywz, [url=http://pyyphgotnnfz.com/]pyyphgotnnfz[/url], [link=http://rfyvxpztwblp.com/]rfyvxpztwblp[/link], http://aytazlaycysx.com/
Gravatar
# pyvqiY <a href="http://itrxuzstyfry.com/">itrxuzstyfry</a>, [url=http://mybcfsliybba.com/]mybcfsliybba[/url], [link=http://jtviikoctebp.com/]jtviikoctebp[/link], http://roahbpzjmgyr.com/
qbasiegfd
3/26/2010 1:33 AM
pyvqiY itrxuzstyfry, [url=http://mybcfsliybba.com/]mybcfsliybba[/url], [link=http://jtviikoctebp.com/]jtviikoctebp[/link], http://roahbpzjmgyr.com/
Gravatar
# HOW TO MAKE $100000 a MONTH AT HOME?
tianic
4/26/2010 11:54 PM
do you like to make more money?
do you like to make money at home?
do you like to make $428 one day?
CLICK HERE :moneymadeeasyongoogle.com
Gravatar
# Christian Louboutin Shoes
Christian Louboutin Shoes
5/30/2010 7:46 AM
nice share, good

article, very usefull for me...thank you
Gravatar
# Christian Louboutin
Christian Louboutin
5/30/2010 12:33 PM
Thanks for best news!
Gravatar
# Christian Louboutin
Christian Louboutin
6/8/2010 3:23 AM
Thanks for good news!
Gravatar
# best registry cleaner
registry cleaner
7/24/2010 9:35 AM
Thanks for posting! I really enjoyed the report. I've already bookmark

this article.
Gravatar
# Independent Wp Themes
WP Themes
8/3/2010 2:31 AM
Nice post and this enter helped me alot in my college assignement. Gratefulness you for your information.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 7 and 6 and type the answer here: