Wim-ms’s Opsmgr 2007 Weblog

A blog about opsmgr 2007

Powershell snippet – add operators

Posted by wim-ms on April 18, 2008

Some code to automatically add some operator roles. Just edit the hash with your own description and groups. Ofcourse, this code requires that you run it from the Opsmgr command shell, or that you add the PSSnapin

$operatorroles=@{"ISA Operators"="DOMAIN\GS.ISA.admins";"Exchange Operators"="DOMAIN\GS.Exchange.admins";"SQL Operators"="DOMAIN\GS.SQL.admins"}

function addOperatorRole {
write-host "adding operator: $operatorname"
$mg=(get-item .).ManagementGroup
$operator=$mg.GetMonitoringProfiles() | where {$_.Name -eq "Operator"}
$obj = new-object Microsoft.EnterpriseManagement.Monitoring.Security.MonitoringUserRole
$obj.MonitoringProfile = $operator

function addOperatorRoles {
write-host "adding Operator Roles"
$operatorroles.getEnumerator() | foreach -process { addOperatorRole $_.Name}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: