Yesterday we published a new KBArticle about Operations Manager Maintenance Mode.
It explains everything you want to know about Maintenance Mode.
What is Maintenance Mode? Maintenance mode is a feature in Operations Manager to suspend monitoring of an object during regular software or hardware maintenance activities like Software Update installations, Hardware replacements, etc.
Read more here.
We have released CU6 for System Center Operations Manager 2007 R2.
Cumulative Update 6 for Operations Manager 2007 R2 includes all previous cumulative updates for Operations Manager 2007 R2 and includes all cross-platform updates.
To download Cumulative Update 6 for Operations Manager 2007 R2, go to the following Microsoft Download Center website:
Download Cumulative Update 6 for System Center Operations Manager 2007 R2 (http://www.microsoft.com/downloads/details.aspx?FamilyID=694147f8-9691-4833-97af-0de918c60141)
Cumulative Update 6 for Operations Manager 2007 R2 resolves the following issues:
System Center Operations Manager 2007 R2 Cross Platform Monitoring Management Packs (http://www.microsoft.com/downloads/details.aspx?FamilyID=b15fef5c-e331-4006-8913-be376bb0e0c1)
My blogpost on the formatting changes for System Center Operations Manager 2012 in Update Rollup 1 has been published on the PowerShell Magazine website.
Take a look at my blogpost if you are interested in the PowerShell formatting changes that have been implemented after the release of UR1. Read more
Today I deployed some new Management Pack in my OM2012 demo environment, and to check if the Management Packs got deployed I checked the Operations Manager Eventlog for eventid 1201.
And because I do this every time when I deploy new Management Packs I created a PowerShell script to check for these events. This is why we invented PowerShell
I wanted to know which Management Packs where deployed since the last hour. No need to retrieve all deployed Management Packs.
$regex = [regex]'"(.*?)"'
#Custom formatting $format = @{Label="MPName-Version";Expression={$regex.Matches($_.Message)}}
get-eventlog -LogName "Operations Manager" -after (get-date).addhours(-1) | Where-Object {$_.Eventid -eq 1201} | Format-Table TimeGenerated, EventId, $format -AutoSize
You can even add the –computername switch to retrieve remote eventids if you want.
While the rest of the System Center community is in Vegas for MMS2012 I’m helping customers with their questions about System Center Operations Manager 2012. To be honest I’m little jealous on all the people who are in Vegas right now.
So I created some more detailed documentation on how to start monitoring your non-domain members (workgroup servers in your DMZ) in OM2012.
It are still the same steps as in OM 2007 so if you already familiar with those steps it would be easy for you.
I created a simple Diagram to have a high-level overview on which steps are being executed on which machines.
Environment:
Some important notes:
Guide info: http://technet.microsoft.com/en-us/library/dd362655.aspx
Pre-reqs:
It is assumed that you have AD CS installed, an HTTPS binding is being used, and its associated certificate has been installed. Information about creating an HTTPS binding is available in the topic How to Configure an HTTPS Binding for a Windows Server 2008 CA.
High-Level steps:
Step 1. Download the Trusted Root (CA) certificate
[OM12MS02.demo.stranger]
Download a CA Certificate, certificate chain, or CRL
Step 2. Import the Trusted Root (CA) Certificate
Open Certificates Local Computer account MMC:
Import Certificate TrustedCA.p7b
Step 3. Create a setup information file to use with the CertReq command-line utility.
Step 4. Create a request file to use with a stand-alone CA
Step 5. Submit a request to a stand-alone CA
Request a certificate
Advanced
Select Submit a certificate request by using a base-64-encoded CMC or PKCS #10 file, or submit a renewal request by using a base-64-encoded PKCS #7 file.
Step 6. approve the pending certificate request
[W2K8R2DC1.demo.stranger]
Click Pending Request in Certificate Authority
Click on Issue
Step 7. retrieve the certificate
View status of pending certificate request
Save certificate
Download certificate
Step 8. import the certificate into the certificate store
Step 9. import the certificate into Operations Manager using MOMCertImport
Note
On 64-bit computers, type cd\SupportTools\amd64
MOMCertImport /SubjectName OM12MS02.demo.stranger
Check if everything is ok
Open the certificate that you installed on management/gateway server. Click on Details Tab and check the Serial Number.
Now navigate to HKLM\Software\Microsoft\Microsoft Operations Manager\3.0\Machine Settings and check the value of ChannelCertificateSerialNumber. Serial number of certificate should be listed backwards here in registry.
Open registry
Tada!
Pre-reqs on DMZ server:
Make sure you have installed the OM12 Agent first before starting.
Let's check the eventlog
Repeat steps for OM12DWZ01 server in workgroup
[OM12DWZ01.demo.dmz]
Step 1. Download the Trusted Root (CA) certificate.
Step 2. Import the Trusted Root (CA) certificate
CertReq –New –f RequestConfig.inf CertRequest.req
[OM12DMZ01.demo.dmz]
MOMCertImport /SubjectName OM12DMZ01.demo.dmz
Final step is approving agent
Check Security Settings in Operations Console.
Wait for Agent to turn up in Pending Approval folder
End result:
Have fun at MMS for those who are in Vegas, and for those who are not, well…
Just a short blogpost to let you know we released the Technical Documentation Download for System Center 2012 – Operations Manager. Go to Microsoft Download Center and download the following documentation.
Overview
The downloadable files listed on this page contain the product documentation for the Operations Manager component of System Center 2012. The available downloads include:
And for you lazy people who don’t want to click for each download I again created a PowerShell script to download them all in on go
############################################################################### # Download all OM12 Documents from # http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29256 # in one-go using PowerShell and BitsTransfer. # Remark: Use PowerShell 2.0 because it makes use of the BitsTransfer Module # Author: Stefan Stranger # v1.002 - 01/04/2012 - stefstr - second release ###############################################################################
$outputfolder = "c:\Temp\OM12Docs"
Import-Module BitsTransfer #Loads the BitsTransfer Module Write-Host "BitsTransfer Module is loaded"
$OM12Docs = @("http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Operations.docx", "http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Authoring.docx", "http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Cmdlets.doc", "http://download.microsoft.com/download/3/3/F/33F52373-3A75-422C-969B-61E05EEC5E72/SC2012_OpsMgr_Deployment.docx") Foreach ($OMDoc in $OM12Docs) { Start-BitsTransfer -source $OMDoc -Destination $outputfolder} Write-Host "OM12 Docs are downloaded to $outputfolder"
Today we released the Microsoft Script Explorer for Windows PowerShell (pre-release).
Microsoft Script Explorer for Windows PowerShell (pre-release) helps scripters find Windows PowerShell scripts, snippets, modules, and how-to guidance in online repositories such as the TechNet Script Center Repository, PoshCode, local or network file systems and Bing Search Repository.
Supported Operating Systems: Windows 7 Service Pack 1, Windows 8 Consumer Preview, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 8 Beta, Windows Vista Service Pack 2
Additional Requirements:
This software is a pre-release version. Features and behavior are likely to change before the final release. This preview release is designed to enable the community to experience and review the preliminary designs and direction of key features in Microsoft Script Explorer and to solicit feedback before features are finalized. If you have additional questions, need help in troubleshooting issues, and other product features visit the Microsoft Script Explorer Forum on TechNet. Your feedback is important to us. Help improving Script Explorer by submitting bugs and suggestions to Microsoft Script Explorer Forum on TechNet.
And start searching for your PowerShell scripts.
Please give use feedback on the Microsoft Script Explorer Forum on TechNet.
Thanks!
Today I was playing around with creating some Dashboard Views with Widgets and wanted to store them in their own Management Pack. All the blogs about creating OM 2012 Dashboards store the Dashboards and Widgets in the Default Management Pack. This is by design because all Views (and the Dashboard View is just another view) are created in the folder you started doing it from.
The only exception to this, is creating a folder (but that’s not a view )
So if you start creating a Dashboard View in the Monitoring folder the Dashboard View is stored in the Default Management Pack.
If you want to store your Dashboard View in another Management Pack than the Default Management Pack, you need to create a new Management Pack (for example create a Test Management Pack) and start creating your Dashboard View under that (Test) folder.
Now your Dashboard View is being stored in the Test Management Pack.
More blogposts about creating Dashboard views are:
Yesterday I blogged about some small improvements to Daniele Grandini blogpost about a great PowerShell script to dump the contents of Management Pack Bundles (.mpb) files and the old MP contents.
But did you knew you can do the same with the new MP Viewer Daniele Muscetta created for OM12?
With MPViewer 1.9 you can also view the contents of mpb (MP Bundles). How cool is that?
After you opened the mpb file go to the Resources folder and BOOM! there you see the contents of the mpb files. How cool is that?
Or some script info like the sql queries
Go get the latest OM12 tools from Daniele Muscetta’s blogpost.
Last week Daniele Grandini posted a great PowerShell script to dump the contents of Management Pack Bundles (.mpb) files and the old MP contents.
The script takes just two parameters an input directory where you have to copy MP and MPB files and an output directory where the dumps will be saved. The OpsMgr 2012 admin console needs to be installed for the script to work properly.
Today I finally had some time to play with OM12 and PowerShell for a session I’m preparing and I also tried to Daniele’s dump management pack bundles PowerShell script. It worked as expected, but the results of the dumped mpb files where stored in the same directory together with all other dumped mpb file contents. And this is not what I wanted.
I would rather have the contents of each dumped mpb file stored in it’s own folder. That way it’s easier to explore the contents of the mpb file IMO.
So I made some small changes to the PowerShell script Daniele created to have each mpb file dump it’s content in it’s own folder.
Now it’s easier to see what has been dumped for each mpb file.
I hope Daniele won’t mind me changing his script slightly to fit my personal preferences
Here is my changed version of Daniele’s script:
param($inDir, $outDir)
[Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core") [Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Packaging")
$mpStore = new-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore($inDir)
$mps = get-childitem $inDir *.mp #$mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir) if ($mps -ne $null) { foreach ($file in $mps) { md ($outDir + "\"+ $file) #ADDED $mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir + "\"+ $file) #ADDED $MPFilePath = $file.FullName $mp = new-object Microsoft.EnterpriseManagement.Configuration.ManagementPack($MPFilePath) Write-Host $file $mpWriter.WriteManagementPack($mp) } } #now dump MPB files $mps = get-childitem $inDir *.mpb $mpbReader = [Microsoft.EnterpriseManagement.Packaging.ManagementPackBundleFactory]::CreateBundleReader() if ($mps -ne $null) { foreach ($file in $mps) { md ($outDir + "\"+ $file) #ADDED $mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir + "\"+ $file) #ADDED $mpb = $mpbReader.Read($file.FullName, $mpStore) foreach($mp in $mpb.ManagementPacks) { #write the xml $mpWriter.WriteManagementPack($mp) $streams = $mpb.GetStreams($mp) foreach($stream in $streams.Keys) { $mpElement = $mp.FindManagementPackElementByName($stream) $fileName = $mpElement.FileName if ($fileName -eq $null) { $fileName = $outDir +'\' + ($mp.Name)+ '.' + $stream+ '.bin' } else { If ($fileName.IndexOf('\') -gt 0) { #only on dir level supported $dir = $outDir + '\' + $fileName.SubString(0, $fileName.IndexOf('\')) if ([System.Io.Directory]::Exists($dir) -ne $true) { [System.Io.Directory]::CreateDirectory($dir) } } #$fileName = "${outdir}\${fileName}" $fileName = $outdir+"\"+$file+"\$filename" #ADDED } Write-Host "`t$fileName" $fs = [system.io.file]::Create($fileName) $streams[$stream].WriteTo($fs) $fs.Close() } } } }
See the comment # for what I changed.
This posting is provided "AS IS" with no warranties, and confers no rights.
Did you know there is a help topic about which cmdlets are new to Operations Manger 2012, which Operations Manager 2007 cmdlets have an equivalent Operations Manager 2012 cmdlet ("renamed" cmdlets), and Operations Manager 2007 cmdlets that have no Operations Manager 2012 equivalent ("deprecated" cmdlets)?
Yes there is Just type Get-Help about_OpsMgr_Cmdlet_Names
Here it is:
TOPIC about_OpsMgr_Cmdlet_Names
SHORT DESCRIPTION Maps the System Center Operations Manager 2007 cmdlets to the Operations Manager 2012 cmdlets.
LONG DESCRIPTION All cmdlets in Operations Manager 2012 have new names, and can be identified by the "SC" preceding the noun name. In some cases, the verb associated with the cmdlet has also been updated.
This topic outlines which cmdlets are new to Operations Manger 2012, which Operations Manager 2007 cmdlets have an equivalent Operations Manager 2012 cmdlet ("renamed" cmdlets), and Operations Manager 2007 cmdlets that have no Operations Manager 2012 equivalent ("deprecated" cmdlets).
------------------------------------------------------------------------ OPERATIONS MANAGER 2012 MODULE NAME ------------------------------------------------------------------------ Operations Manager 2007 snap-in Microsoft.EnterpriseManagement.OperationsManager.Client
Operations Manager 2012 module OM10
------------------------------------------------------------------------ NEW OPERATIONS MANAGER 2012 CMDLETS ------------------------------------------------------------------------
Enable-SCOMAgentProxy Disable-SCOMAgentProxy Enable-SCOMDiscovery Disable-SCOMDiscovery Set-SCOMManagementGroupConnection Enable-SCOMMonitor Disable-SCOMMonitor Enable-SCOMMonitoringRule Disable-SCOMMonitoringRule Get-SCOMRunAsProfile Update-SCOMRunAsProfile
------------------------------------------------------------------------ RENAMED CMDLETS ------------------------------------------------------------------------
Operations Manager 2007 Name Operations Manager 2012 Name ---------------------------- ---------------------------- Get-Agent Get-SCOMAgent Install-Agent Install-SCOMAgent Uninstall-Agent Uninstall-SCOMAgent Approve-AgentPendingAction Approve-SCOMPendingManagement Get-AgentPendingAction Get-SCOMPendingManagement Reject-AgentPendingAction Deny-SCOMPendingManagement Get-Alert Get-SCOMAlert Resolve-Alert Set-SCOMAlert Set-AlertDestination Set-SCOMAlert Get-AlertHistory Get-SCOMAlertHistory Get-Connector Get-SCOMConnector Get-Diagnostic Get-SCOMDiagnostic Remove-DisabledMonitoringObject Remove-SCOMDisabledClassInstance Get-Discovery Get-SCOMDiscovery Get-Event Get-SCOMEvent Get-FailoverManagementServer Get-SCOMAgentManagementServerSetting Get-GatewayManagementServer Get-SCOMGatewayManagementServer Get-MaintenanceWindow Get-SCOMMaintenanceMode New-MaintenanceWindow Start-SCOMMaintenanceMode Set-MaintenanceWindow Update-SCOMMaintenanceMode Get-ManagementGroupConnection Get-SCOMManagementGroupConnection New-ManagementGroupConnection New-SCOMManagementGroupConnection Remove-ManagementGroupConnection Remove-SCOMManagementGroupConnection Export-ManagementPack Export-SCOMManagementPack Get-ManagementPack Get-SCOMManagementPack Install-ManagementPack Import-SCOMManagementPack Uninstall-ManagementPack Remove-SCOMManagementPack Get-ManagementServer Get-SCOMManagementServer Set-ManagementServer Set-SCOMAgentManagementServerSetting Set-ManagementServer Set-SCOMAgentManagementServerSetting Get-Monitor Get-SCOMMonitor Get-MonitorHierarchy Get-SCOMMonitor Get-MonitoringClass Get-SCOMClass Get-MonitoringObject Get-SCOMClassInstance Get-MonitoringObjectGroup Get-SCOMGroup Get-NotificationAction Get-SCOMNotificationAction Get-NotificationEndpoint Get-SCOMNotificationEndpoint Get-NotificationRecipient Get-SCOMNotificationRecipient Disable-NotificationSubscription Disable-SCOMNotificationSubscription Enable-NotificationSubscription Enable-SCOMNotificationSubscription Get-NotificationSubscription Get-SCOMNotificationSubscription Get-Override Get-SCOMOverride Get-PrimaryManagementServer Get-SCOMAgentManagementServerSetting Set-ProxyAgent Set-SCOMAgentlessManagedComputer Get-Recovery Get-SCOMRecovery Get-RelationshipClass Get-SCOMRelationship Get-RelationshipObject Get-SCOMRelationshipInstance Add-RemotelyManagedComputer Add-SCOMAgentlessManagedComputer Get-RemotelyManagedComputer Get-SCOMAgentlessManagedComputer Remove-RemotelyManagedComputer Remove-SCOMAgentlessManagedComputer Get-ResultantCategoryOverride Get-SCOMOverride Get-ResultantRuleOverride Get-SCOMOverride Get-ResultantUnitMonitorOverride Get-SCOMOverride Get-Rule Get-SCOMMonitoringRule Get-RunAsAccount Get-SCOMRunAsAccount Get-Task Get-SCOMTask Start-Task Start-SCOMTask Get-TaskResult Get-SCOMTaskResult Get-UserRole Get-SCOMUserRole Add-UserToUserRole Update-SCOMUserRole
------------------------------------------------------------------------ DEPRECATED OPERATIONS MANAGER 2007 CMDLETS ------------------------------------------------------------------------
Install-AgentByName Get-AlertDestination Remove-ConnectorFromTier Add-ConnectorToTier New-CustomMonitoringObject Get-DefaultSetting Set-DefaultSetting New-DeviceDiscoveryConfiguration Get-Diagnostic Start-Discovery New-LdapQueryDiscoveryCriteria Get-MonitoringClassProperty Get-MonitoringObjectPath Get-MonitoringObjectProperty New-MonitoringPropertyValuePair Get-NotificationAction Get-NotificationEndpoint Get-NotificationRecipient Disable-NotificationSubscription Enable-NotificationSubscription Get-NotificationSubscription Get-OperationsManagerCommand Get-PerformanceCounter Get-PerformanceCounterValue Get-Recovery Add-RemotelyManagedDevice Get-RemotelyManagedDevice Remove-RemotelyManagedDevice Get-RootManagementServer Disable-Rule Enable-Rule Get-State Get-Tier New-Tier Remove-Tier New-WindowsDiscoveryConfiguration
SEE ALSO about_OpsMgr_WhatsNew
Last week I had to some long car drives to one of our customers and had plenty of time to listen to some of my favorite podcasts like the PowerScripting Podcasts and Inside Central Podcasts. And in Episode 12 both of my favorite topics where discussed, PowerShell and Operations Manager.
In this episode Pete Zerger and Dan Kregor discuss some of the changes you can expect to see to the Command Shell in OpsMgr 2012. And to my surprise they mentioned some of the PowerShell and OM12 stuff I blogged about
And because I love to dive into the new OM12 Cmdlets and Functions here some more things to explore.
If you looked at my blogpost about what’s new in OM12 for PowerShell you may have noticed that in OM12 we don’t have the Resolve-Alert in OM12. We now have the Set-SCOMAlert Cmdlet.
If we look at the help for the Set-SCOMAlert Cmdlet we see the following:
get-help Set-SCOMAlert
NAME Set-SCOMAlert SYNOPSIS Changes the properties of the specified alert. SYNTAX Set-SCOMAlert [-Alert] <MonitoringAlert[]> [[-CustomField7] <String>] [[-CustomField8] <String>] [[-CustomField9] <String>] [[-Owner] <String>] [[-ResolutionState] <Byte>] [[-TicketId] <String>] [[-Connector] <MonitoringConnector>] [[-CustomField1] <Strin g>] [[-CustomField10] <String>] [[-CustomField2] <String>] [[-CustomField3] <String>] [[-CustomField4] <String>] [[-CustomField5] <String>] [[-CustomField6] <String>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>] DESCRIPTION The Set-SCOMAlert cmdlet changes the properties of the specified alert.
RELATED LINKS Online Version: http://go.microsoft.com/fwlink/?LinkID=187701 Get-SCOMAlert Get-SCOMConnector
REMARKS To see the examples, type: "get-help Set-SCOMAlert -examples". For more information, type: "get-help Set-SCOMAlert -detailed". For technical information, type: "get-help Set-SCOMAlert -full".
Do you see there is no Comment property like we had in the OpsMgr 2007 Resolve-Alert Cmdlet?
Look at the examples:
get-help Set-SCOMAlert -examples
NAME Set-SCOMAlert SYNOPSIS Changes the properties of the specified alert. -------------------------- EXAMPLE 1 -------------------------- PS C:\>Get-SCOMAlert -ResolutionState 15 | Set-SCOMAlert -ResolutionState 255 Description ----------- This command gets all alerts with a resolution state of 15 and then uses the pipeline operator (|) to pass the alert objects to the Set-SCOMAlert cmdlet which closes the alert by setting the resolution state to 255. -------------------------- EXAMPLE 2 -------------------------- PS C:\>Get-SCOMAlert -Name "Failed Accessing Windows Event Log" | Set-SCOMAlert -Owner "CONTOSO\Isabel" -CustomField1 "Root Cause - Permissions" Description ----------- This command gets all alerts named "Failed Accessing Windows Event Log" and then uses the pipeline operator to pass the alert objects to the Set-SCOMAlert cmdlet which changes the owner and sets the value for CustomField1.
When we look at the help for the OpsMgr 2007 R2 Resolve-Alert Cmdlet we see the following:
>get-help resolve-alert
NAME Resolve-Alert
SYNOPSIS Resolves an alert.
SYNTAX Resolve-Alert [-Alert] <MonitoringAlert> [[-Comment] [<String>]] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION Resolves an alert.
RELATED LINKS Get-Alert Get-AlertHistory
REMARKS To see the examples, type: "get-help Resolve-Alert -examples". For more information, type: "get-help Resolve-Alert -detailed". For technical information, type: "get-help Resolve-Alert -full".
This Cmdlet has different parameters then the Set-SCOMAlert Cmdlet, so we need to find some workarounds to solve this.
If we still want to use the Resolve-Alert Cmdlet in OM12 we can easily create a function that does the same as the old Resolve-Alert Cmdlet. We just need to use Set-SCOMAlert with a ResolutionState of 255 to achieve the same result as the old resolve-alert cmdlet.
Open your favorite PowerShell Editor and create a new Resolve-SCOMAlert Function.
<# .SYNOPSIS Resolves an Alert .DESCRIPTION Resolves an Alert .PARAMETER Alert Specifies the alert to resolve. You can use Get-Alert to create an object to pass as the value of this parameter. .PARAMETER Comment Specifies a comment to associate with the resolved alert. .PARAMETER WhatIf Describes what would happen if you executed the command without actually executing the command. .PARAMETER Confirm Prompts you for confirmation before executing the command. .EXAMPLE C:\PS\get-SCOMalert | where-object {$_.Owner -eq "kenmeyers"} | resolve-SCOMalert -comment "Resolving all of Ken's alerts." This command uses Get-SCOMAlert to retrieve all alerts. It then pipes the results to Where-Object to only select the ones owned by Ken Meyers. The alerts that pass the filter are piped to Resolve-SCOMAlert to be resolved with the comment, "Resolving all of Ken's alerts." .EXAMPLE C:\PS>$alerts = get-scomalert | where-object {$_.ResolutionState -eq 0}
foreach($alert in $alerts) { resolve-alert -comment "Resolving Alert" -Alert $alert }
This command uses Get-Alert to retrieve unresolved alerts. Unresolved alerts have a resolution state equal to 0. The command then loops through all the unresolved alerts, calling Resolve-Alert to resolve each of them. The comment "Resolving Alert" is associated with each resolved alert. #>
function Resolve-SCOMAlert { <# -Mandatory - a boolean saying whether the parameter is required or not. A mandatory parameter that is not specified generates a run time exception. -Position – an integer specifying where parameter’s order. As you can see in the above example, the $User paramater is the third parameter, while $domain is the first and $computer the second. -ValueFromPipeline – a boolean indicating if the parameter can come from the pipeline. #> [CmdletBinding()] PARAM( [Parameter(Position=0, ValueFromPipeline=$true, Mandatory=$true)] $Alert , [Parameter(ValueFromPipeline=$true,Mandatory=$false)] [AllowEmptyString()] [string]$Comment , [Parameter(Mandatory=$false)] [boolean]$Whatif , [Parameter(Mandatory=$false)] [boolean]$Confirm )
#Set Resolutionstate Parameter for Set-SCOM Alert $RState = "255" set-variable $RState -option constant # The constant option write protect the resolutionstate property.
# Call now the Set-SCOMAlert with the default parameter –ResolutionState 255 if ($PSBoundParameters.TryGetValue('Comment', [ref]$Comment)) { #There is no Comment Parameter in the Set-SCOMAlert Cmdlet, so we use CustomField1 for the Comment. $PSBoundParameters.Remove('Comment') | Out-Null $PSBoundParameters.Add('CustomField1', $Comment) }
#Call the new OM12 Set-SCOMAlert Cmdlet with the correct parameters Set-SCOMAlert @psboundparameters -ResolutionState $RState }
We start the new function with some help info. I just copied the help info from the old Resolve-Alert Cmdlet and only changed Resolve-Alert to the new naming convention in OM12 Resolve-SCOMAlert.
Then I created a new Function called Resolve-SCOMAlert, which has the same parameters as the old Resolve-Alert Cmdlet, with a default value of 255 for the ResolutionState parameter.
Because the Set-SCOMAlert is missing the Comment property we need to remove the Comment parameter from the $PSBoundParameters and replace that with a new CustomField1 property.
Ok, let’s check if our new Resolve-SCOMAlert Function is working the same as our old Resolve-Alert Cmdlet in OpsMgr 2007.
Open the Operations Console and pick an Alert we want to resolve.
We are going to resolve the “IIS Restart is required” Alert using our new Resolve-SCOMAlert function.
Open the Operations Manager Shell and load the new Resolve-AlertSCOM Function by dotsourcing the above script.
We can now show the help of the new Resolve-SCOMAlert function with the usual get-help cmdlet.
Now we can try to use the resolve-scomalert function on our “IIS Restart is required”
We first need to get the “IIS Restart is required” alert using the new OM12 Get-SCOMAlert Cmdlet.
When we use some formatting and extra properties we see that this is our Alert we want to resolve.
The final step is resolve this alert and add a comment.
get-scomalert | where {$_.Name -eq "IIS Restart is required"} | resolve-SCOMAlert -Comment "Resolved with new Resolve-SCOMAlert Function"
Now let’s check if our Alert is being resolved and has the Comment in CustomField1.
It worked!
If you want to use the Whatif or the Confirm parameter you just need to add $true after those parameters. Example:
Disclamer: Posts in this blog are provided "AS IS" with no warranties, and confers no rights. Included script is an example script.
Hi people I need your help. Today I was looking at the Get-SCOMRMSEmulator cmdlet in OM12 RC and noticed that when running this Cmdlet I got the following WARNING: column "Id" does not fit into the display and was removed"
I solved it by using the Format-Table Autosize cmdlet, but would not it be better if this Warning is not shown when running the cmdlet?
So I created a Suggestion on Microsoft Connect to get this fixed. So please vote on Connect if you also want us to fix this for the next release.
I also suggested to remove the Id property from the default output shown. This is not adding any valuable information about the RMS Emulator anyway. (to my knowledge)
Maybe you can suggest better properties to show.
/Stefan
Now everybody has downloaded OM12 Release Candidate, it’s time to start exploring. Let’s start exploring the registry of the Management Servers for OM12.
And off course we are going to use PowerShell to browse through the OM12 Registry.
Let’s open the registry for OM12 on our first Management Server by starting PowerShell with the Run as Administrator option.
cd "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager"
get-childitem –recursive
With the following command we get the properties of the different registry keys.
First set the $ErrorActionPreference = silentlycontinue (this will make sure we don’t see any error messages, which I got due to an issue with long file names)
Get-ChildItem 'hklm:\software\microsoft\microsoft operations manager' -Recurse | ForEach-Object {Get-ItemProperty $_.pspath}
But would not it be nice to compare the registry keys between two Management Servers?
I found that exporting the registry keys using Regedit and than using the Compare-Object cmdlet was the easiest way to use.
You can use the following command to export the Microsoft Operations Manager keys.
regedit /e d:\temp\exportregkeyserver1.reg "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\Microsoft Operations Manager"
Just use the same command (only change the name of the file you want to export the registry key to) on your other Management Server and copy the result to your first Management Server.
Now we can use the Compare-Object Cmdlet to compare the different Registry keys from the two Management Servers.
Compare-Object $(Get-Content "D:\temp\exportregkeyserver1.reg") $(Get-Content "D:\temp\exportregkeyserver2.reg") | ft –wrap
So the most important differences between the Management Server I installed first and the second Management Server is the Reporting Key:
get-itemproperty "hklm:\software\microsoft\microsoft operations Manager\3.0\Reporting"
Don’t forget to change you $ErrorActionPreference = continue
Have fun exploring OM12
Source: System Center Central
Now that we have released System Center 2012 Release Candidate is time to start installing this release in you test environment.
But you can already start using our Technical Virtual Labs.
TechNet Virtual Labs enable you to quickly evaluate and test Microsoft's newest products and technologies through a series of guided, hands-on labs that you can complete in 90 minutes or less. There is no complex setup or installation required, and you can use TechNet Virtual Labs online immediately, free.
Sorry for not being able to post some blogposts lately, but I’m just too busy ramping up on all our new products
This week I started to play with Windows 8 and of course one of the first things I looked for was PowerShell 3.0 And then I found a great blogpost on the PowerShellMagazine website by Shay Levy where he shows how find all the changes between the two versions of PowerShell (v2 and v3).
That’s when I thought why not use the same approach for finding the changes between the OpsMgr 2007 R2 PowerShell Commands and the OM12 PowerShell Commands.
This is the script I slightly modified to get it to work for OpsMgr 2007 and OM12.
# Compare differences OpsMgr 2007 PowerShell Commands and OM 12 PowerShell Commands. # Idea and initial script from Shay Levy on PowerShellMagazine. (http://www.powershellmagazine.com/2011/09/15/how-to-find-out-whats-new-in-powershell-vnext) # Small changes by Stefan Stranger # Date: 21-09-2011
#Run in OpsMgr 2007 Command Shell Get-Command -Module Microsoft.EnterpriseManagement.OperationsManager.Client | Select-Object -Property Name,@{Name='Parameters';Expression={(Get-Command $_).Parameters.Keys}} | Export-Clixml d:\temp\opsmgr2007.xml
#Run in OM12 Command Shell Get-Command -Module OperationsManager | Select-Object -Property Name,@{Name='Parameters';Expression={(Get-Command $_).Parameters.Keys}} | Export-Clixml d:\temp\om12.xml
# run either in OpsMgr2007 or OM12 console $OpsMgr2007 = Import-CliXml d:\temp\opsmgr2007.xml | Sort-Object -Property Name $OM12 = Import-CliXml d:\temp\om12.xml | Sort-Object -Property Name
Compare-Object $OpsMgr2007 $OM12 -Property Name -IncludeEqual -PassThru | ForEach-Object {
$Command = $_
if($_.SideIndicator -eq ‘==’) { $Command = $_
$cOpsMgr2007 = $OpsMgr2007 | Where-Object {$_.Name -eq $Command.Name} | Select-Object -ExpandProperty Parameters $cOM12 = $OM12 | Where-Object {$_.Name -eq $Command.Name} | Select-Object -ExpandProperty Parameters
$compare = Compare-Object $cOpsMgr2007 $cOM12
if($compare) { try { $NewParameters = $compare | Where-Object {$_.SideIndicator -eq ‘=>’} | ForEach-Object {$_.InputObject + ‘ (+)’} $RemovedParameters = $compare | Where-Object {$_.SideIndicator -eq ‘<=’} | ForEach-Object {$_.InputObject + ‘ (-)’}
“$($command.Name) (!)” $NewParameters + $RemovedParameters | Sort-Object | ForEach-Object { “`t$_”} “`n” } catch{} } } elseif($_.SideIndicator -eq ‘=>’) { “$($Command.name) (+)`n” } else { “$($Command.name) (-)`n” } }
OpsMgr 2007 Command Shell
OM12 Command Shell
Legend
> Changed + > New - > Removed
Most of the changes are changes in the noun naming convention Example: Get-Alert is changed in Get-SCOMAlert.
Have fun!
Last week I was asked to help a customer with the configuration of an OpsMgr 2007 R2 connector. Because I had not much hands on experience with the installation and configuration of the OpsMgr 2007 R2 Connectors I installed an configured the Universal Connector in my own test/demo environment.
And because I learned some new things during this exercise I thought it would be a good idea to share some of my experiences. Warning, this turned out to be become a long blogpost. Stop reading here if you can only read short (twitter) messages
Downloads:
I started downloading the free connectors from Microsoft Downloads. This release of the Operations Manager 2007 R2 Connectors includes the following Connectors:
Documentation:
If you extract the downloaded SCInterop_R2_RTM.zip file there is a Docs folder with 4 files of documentation you should be READING before installing the Connectors.
Tools:
I used the following tools to install and configure the Universal Provider on my SLES10 system:
You should start reading the Release Notes (OM2007_ConnectorsRn.htm) thoroughly before you install or upgrade any Operations Manager 2007 R2 Connectors. The next step is reading the Operations Manager 2007 R2 Connectors Deployment Guide (OM2007_Connectors.doc). Here you can check the System Requirements. In my test/demo environment I’ve installed the Connector Service and Configuration UI on a Windows Server 2008 R2 system without any issues. But be aware this is not supported (yet).
Other documentation I used to get ready for the installation is this blogpost from our famous Kevin Holman Installing the OpsMgr R2 Universal Connector.
Operations Manager 2007 Connectors Architecture:
High-Level Installation Steps:
For the detailed installation steps see the Operations Manager 2007 R2 Connectors Deployment Guide but I’ll show some tips and tricks I used to get the Universal Connector installed and configured.
Tips & Tricks:
Step 1. Check Pre-requisites on both systems.
How do you check if WSMan is installed on a Windows system?
You can check if WSMan is installed using the next command from the command prompt:
winrm identify
So on my Windows 2008 R2 RMS (where I’ll be installing the Universal Connector Service and UI) WSMan is running.
How can check if WSMan is running on the remote SLES10 machine?
Keep in mind that during the install of the SCX agent (Interop core) first the wsman components (Open Pegasus) will be installed and later the Univeral provider will be installed on top of the SCX agent.
So it would be “normal” not having wsman installed on the remote SLES10 machine. But in case you want to check anyway. You could check for the cimserver process on the SLES10 machine using the next command in Putty:
ps –eaf | grep cimserver
The winrm also has a remote parameter. winrm id –remote:nameofremoteserver.com
Let’s try to run this from the RMS server.
It seems we don’t have the correct permissions to do this. Let’s try to use the winrm’s INVOKE verb. More info on the use of the INVOKE verb can be found at Daniele Muscetta’s blogpost about winrm and invoke.
Run the following command from a Windows machine:
winrm invoke ExecuteCommand http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx @{command="ps -eaf";timeout="60"} -username:root -password:Password -auth:basic -r:https://suse10:1270/wsman -skipCACheck -encoding:UTF-8
There we have it, all running processes on the SLES10 machine using WSMan. Keep in mind this test was run AFTER I had installed the Interop core which also installs Open Pegasus.
Do I need to install the 32-bit version of the Microsoft Visual C++ 2008 Redistributable Package (x86) on a 64-bit Windows 2008 R2 server?
Yes you need to install the x86 version on a 64-bit OS.
Step 2. Install Universal Provider on SUSE10 server (always first start with the Provider)
How do I copy the Universal Provider files to my SLES10 server?
Use WinSCP to connect from your Windows server, where you have the installation files for the connectors to the SLES10 server. Copy the correct OS version files (in my case I copied the files from the Linux_SUSE_10.0_x86_32 folder) to a location (/tmp) on the remote SLES10 server.
How do I install the Universal Provider on my SLES10 server?
Use Putty to make a connection to the remote SLES10 machine. Logon with an account which has enough privileges to install the software (I used the root account for the installation of the Universal Provider).
The first part of the installation is the installation of the the SCX agent first (Interop core) the wsman components (Open Pegasus)
run the following command in your Putty session: rpm –i /tmp/Linux_SUSE_10.0_x86_32/scx-1.0.4-248.sles.10.x86.rpm
The second part of the installation is the installation of the Universal Provider.
Run the next command in your Putty session: Rpm -i MSFTscinteropUnv-6.17000-58.suse.10.x86.rpm
You can check the result of the installation in the /tmp/scinterop_install.out file using cat or WinSCP if you want.
Step 3. Install Universal Connector Service and Configuration on Windows Server 2008 R2 Server
Install the Universal Connector and UI using an elevated command prompt.
Which Features do I need to select during the installation of the Universal Connector and UI?
Select Entire feature will be installed on local harddrive.
Remark: You can change the location where the Universal Connector Service is installed if you want.
Which account be used for the Connector Service?
After the installation of the Universal Connector Service a new database SCInterop is created.
One step in the configuration is granting the Connector Service Account (SDK account) enough permissions for the SCInterop database. The SDK Config account need db_owner permissions.
Now it’s time to configure the Universal Connector.
Which User name do I use for the WS-Man server credentials?
Enter the next settings:
Instead of using the root account on the SLES10 server where I installed the Universal Provider I created a scxuser account.
The scxuser is member of the following groups on the SLES10 server:
The next step in the Configuration is testing the connection.
The first time I tested the connection I got an error message.
Before clicking on Yes to continue the configuration I opened a command prompt to test the connection using the scxuser account.
Run the following command from the command prompt: winrm enumerate http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx -username:scxuser -password:Password -r:https://suse10:1270/wsman -auth:basic -skipCACheck -encoding:UTF-8
There seems something wrong with the SSL certificate.
The Connector requires the use of certificates to validate the authenticity of the server on which the Interop Provider is running. The Connector does not work until the certificate has been transferred and correctly imported to the server on which Connector is running (Windows 2008 R2 RMS Server) from the server on which the Interop Provider (SLES10 Server) is running. During the Interop Provider installation, a self-signed certificate is generated and stored in the Interop Provider installation directory. The Connector Certificate Retrieval and Installation wizard retrieves the certificate and automatically installs it on the server on which the Connector is running. Installing the Connector certificate at installation is optional. However, the Connector certificate must be installed on the server on which the Connector is running before the Connector service is started. If you do not install the Interop Provider certificate, the Connector cannot communicate with the server on which the Interop Provider is running.
Fixed it by following the next steps:
1. Copied the scx-host-suse10.pem file to the RMS server
2. Runned scxcertconfig -sign scx-host-suse10.pem scx_new.pem on RMS
3. Copied the scx_new.pem file to the SUSE10 box (Provider) and renamed it to scx-host-suse10.pem
4. Restarted scxadmin –restart (on the SLES10 server)
5. Tested WSMan connection to provider from RMS.
In the Universal Connector folder there is a tool called scicert.exe which can be used to test the connection.
Run the following command from the command prompt:
scicert suse10 scxuser Password "OpsMgr Universal Connector" test
Seems to be working ok, right now
You can also use the winrm enumerate command if you want to:
winrm enumerate http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx -username:scxuser -password:Password -r:https://suse10:1270/wsman -auth:basic -skipCACheck -encoding:UTF-8
We now have the Universal Connector installed and configured, now we need to test if OpsMgr Alerts will be forwarded from OpsMgr to the Universal Provider on the SLES10 server.
High-Level Steps to test the Universal Connector.
Step 1. Add a new subscription for alerts that you want to send to the connector.
Go to Administration Pane and select Internal Connectors folder. Select the OpsMgr Universal Connector.
Double click on the OpsMgr Universal Connector. In the properties of the OpsMgr Universal Connector enter a Subscription Name and optionally a Description.
Click Next and configure the Groups criteria
Click Next and configure the Targets.
Click Next and configure the Alert Criteria
And in the last screen click OK to save your Subscription.
Step 2. Create a Test Event Rule.
Just follow the normal steps to create an Event Alert Rule which get’s triggered by eventid 999.
Every time an event 999 is created an Alert is generated.
Just use the EventCreate.exe tool to create an Event 999 from the command prompt:
eventcreate.exe /T ERROR /ID 999 /L APPLICATION /D "Testing Universal Connector"
Result:
Before we look at what happens on the Remote Universal Provider we need to have some background info on the New Alert Data workflow.
New Alert Data Flow in the Universal Connector:
Step 1 and 2. The Operations Manager alert is forwarded to remote system in either XML or Key=Value Pair(evt) file format and The universal provider on the remote system creates a file (xml or property file) in a specified directory
We can check if the OpsMgr Alert is forwarded to the remote Universal Provider, which I configured to be in XML format, by opening WinSCP and look in the following folder: /opt/microsoft/scx/UnvEvents/FromOpsMgr
Let’s create a new Alert by creating a new 999 EventID and check if there will created an XML file in the /opt/microsoft/scx/UnvEvents/FromOpsMgr folder
Now look at the remote folder and check if we see the xml file on the Universal Provider.
Let’s check the contents of the xml file.
<?xml version="1.0" encoding="utf-8"?> <UNVEvent> <AlertId>c16964d1-b01d-4e44-99c9-d892d28fe680</AlertId> <ComputerDomain>DEMO</ComputerDomain> <ComputerName>OPSMGRR2RMS</ComputerName> <Description>Event Description: Testing Universal Connector</Description> <EventType>0</EventType> <ManagementGroupName>DEMOMG</ManagementGroupName> <ManagementPack>Stefan.Test.Universal.Connector</ManagementPack> <ManagementServer>opsmgrr2rms</ManagementServer> <ModifiedBy>DEMO\OM_Admin</ModifiedBy> <MonitoringClassName>Microsoft.Windows.Computer</MonitoringClassName> <MonitoringObjectHealthState>Success</MonitoringObjectHealthState> <MonitoringObjectInMaintenanceMode>False</MonitoringObjectInMaintenanceMode> <MonitoringObjectName>OPSMGRR2RMS.DEMO.STRANGER</MonitoringObjectName> <Name>Stefan - Test Universal Connector Event Rule</Name> <Priority>Normal</Priority> <ProblemId>afcc789a-d227-37a2-79ff-70c6cf469eba</ProblemId> <RepeatCount>0</RepeatCount> <ResolutionState>255</ResolutionState> <RuleName>MomUIGeneratedRule75cfefecc3264771af35f117e44a64ff</RuleName> <RuleTarget>Microsoft.Windows.Computer</RuleTarget> <Severity>2</Severity> <TimeOfLastEvent>2011-08-15T16:48:43.557Z</TimeOfLastEvent> <WebConsoleUrl>http://OPSMGRR2RMS:51908/default.aspx?DisplayMode=Pivot&AlertID=c16964d1-b01d-4e44-99c9-d892d28fe680</WebConsoleUrl> </UNVEvent>
Let’s also check if something has changed on the OpsMgr side.
We don’t see a new Ticked ID or Owner change. The only indication we see is that the History has some info.
Step 3. The custom integration logic picks up file from specified directory and inserts data into the remote system application.
Now the Universal EMS should pick up the xml file from the /opt/microsoft/scx/UnvEvents/FromOpsMgr and change this data in the EMS (Enterprise Management System). We can do the same manually if we want to test this.
Steps:
1. Create a new directory called "<Provider Install Directory>\UnvEvents\<MgmtGrpName>\ using WinSCP on the SLES10 server.
2. Create a directory called "<Provider Install Directory>\UnvEvents\<MgmtGrpName>\EMS". This directory will contain a evt/xml file with all the necessary information about the alert that is in sync with the connector. If you close the alert in OpsMgr this file will be deleted, acknowledging that the alert was closed.
3. You can manipulate the evt/xml file in the EMS directory then drop it into the "<Provider Install Directory>\UnvEvents\<MgmtGrpName>" directory to send updates back to the OpsMgr alert.
To send an update back to OpsMgr the EventType variable must always be set to 1 (e.g.; EventType=1 or <EventType>1</EventType>).
Fields that can be update on the OpsMgr alert from the EMS side:
Let's update the Alert:
Copy file c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml from /opt/microsoft/scx/UnvEvents/FromOpsMgr to /opt/microsoft/scx/UnvEvents/DEMOMG/EMS folder
cp /opt/microsoft/scx/UnvEvents/FromOpsMgr/c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml /opt/microsoft/scx/UnvEvents/DEMOMG/EMS
Edit c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml
<?xml version="1.0" encoding="utf-8"?> <UNVEvent> <AlertId>c16964d1-b01d-4e44-99c9-d892d28fe680</AlertId> <ComputerDomain>DEMO</ComputerDomain> <ComputerName>OPSMGRR2RMS</ComputerName> <Description>Event Description: Testing Universal Connector</Description> <EventType>0</EventType> <ManagementGroupName>DEMOMG</ManagementGroupName> <ManagementPack>Stefan.Test.Universal.Connector</ManagementPack> <ManagementServer>opsmgrr2rms</ManagementServer> <ModifiedBy>DEMO\OM_Admin</ModifiedBy> <MonitoringClassName>Microsoft.Windows.Computer</MonitoringClassName> <MonitoringObjectHealthState>Success</MonitoringObjectHealthState> <MonitoringObjectInMaintenanceMode>False</MonitoringObjectInMaintenanceMode> <MonitoringObjectName>OPSMGRR2RMS.DEMO.STRANGER</MonitoringObjectName> <Name>Stefan - Test Universal Connector Event Rule</Name> <Priority>Normal</Priority> <ProblemId>afcc789a-d227-37a2-79ff-70c6cf469eba</ProblemId> <RepeatCount>0</RepeatCount> <ResolutionState>0</ResolutionState> <RuleName>MomUIGeneratedRule75cfefecc3264771af35f117e44a64ff</RuleName> <RuleTarget>Microsoft.Windows.Computer</RuleTarget> <Severity>2</Severity> <TimeOfLastEvent>2011-08-15T16:48:43.557Z</TimeOfLastEvent> <WebConsoleUrl>http://OPSMGRR2RMS:51908/default.aspx?DisplayMode=Pivot&AlertID=c16964d1-b01d-4e44-99c9-d892d28fe680</WebConsoleUrl> </UNVEvent>
<?xml version="1.0" encoding="utf-8"?> <UNVEvent> <AlertId>c16964d1-b01d-4e44-99c9-d892d28fe680</AlertId> <ComputerDomain>DEMO</ComputerDomain> <ComputerName>OPSMGRR2RMS</ComputerName> <Description>Event Description: Testing Universal Connector</Description> <EventType>1</EventType> <ManagementGroupName>DEMOMG</ManagementGroupName> <ManagementPack>Stefan.Test.Universal.Connector</ManagementPack> <ManagementServer>opsmgrr2rms</ManagementServer> <ModifiedBy>DEMO\OM_Admin</ModifiedBy> <MonitoringClassName>Microsoft.Windows.Computer</MonitoringClassName> <MonitoringObjectHealthState>Success</MonitoringObjectHealthState> <MonitoringObjectInMaintenanceMode>False</MonitoringObjectInMaintenanceMode> <MonitoringObjectName>OPSMGRR2RMS.DEMO.STRANGER</MonitoringObjectName> <Name>Stefan - Test Universal Connector Event Rule</Name> <Priority>Normal</Priority> <ProblemId>afcc789a-d227-37a2-79ff-70c6cf469eba</ProblemId> <RepeatCount>0</RepeatCount> <ResolutionState>255</ResolutionState> <RuleName>MomUIGeneratedRule75cfefecc3264771af35f117e44a64ff</RuleName> <RuleTarget>Microsoft.Windows.Computer</RuleTarget> <Severity>2</Severity> <TimeOfLastEvent>2011-08-16T10:44:19.830Z</TimeOfLastEvent> <WebConsoleUrl>http://OPSMGRR2RMS:51908/default.aspx?DisplayMode=Pivot&AlertID=1fbc6201-773f-4680-a120-e6e7e684cd8e</WebConsoleUrl> <OwnerName>EMS</OwnerName> <CustomField1>Manual Test of EMS</CustomField1> </UNVEvent>
Drop it into the "/opt/microsoft/scx/UnvEvents/DEMOMG
cp /opt/microsoft/scx/UnvEvents/DEMOMG/EMS/c16964d1-b01d-4e44-99c9-d892d28fe680.1.xml /opt/microsoft/scx/UnvEvents/DEMOMG
Is gone in seconds
Works ok :-)
I also created a PowerShell script which retrieves the remote xml file so you can check what has been forwarded from the Universal Connector to the Remote Universal Provider. But I need some more time to improve this script.
Here is a first example on how I started. If I’ve more time I’ll create a blogpost on how to create a PowerShell EMS tool.
#use winrm with invoke to retrieve the last xml file from the remote Universal Provider [string]$AlertFromUnvConn = cmd /c 'winrm invoke ExecuteShellCommand http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx @{command="ls -1t /opt/microsoft/scx/UnvEvents/FromOpsMgr/*.xml | head -1 | xargs cat";timeout="60"} -username:root -password:Password -auth:basic -r:https://suse10:1270/wsman -skipCACheck -encoding:UTF-8' $subject = $AlertFromUnvConn
#Parse the result so we can use this fix the returned XML if ($subject -cmatch '(?si)<UNVEvent\b[^>]*>(.*?)</UNVEvent>') { $result = $matches[0] } else { $result = '' }
#Convert result to genuine xml [xml]$xml = $result
#Show Result $xml.UNVEvent | format-list
Now that System Center Operations Manager 2012 (OM12) Beta available is, it’s time to compare the OM12 Command Shell with the OpsMgr 2007 Command Shell.
Snapin vs Module
OpsMgr 2007 has a PoweShell Snapin and OM12 uses a PowerShell Module. Modules are a new feature of PowerShell v2 are now widely used in PowerShell. Modules allow you a cleaner way to work with groups of scripts, because they can contain private variables that only those scripts share. You can also refer to a function within a module, which allows you to group commands more logically and to use more common function names without fear of overwriting the names of other functions. More info can be found here.
How do you know if Snapins or Modules are being used?
Just open the Operations Manager Shell in OpsMgr 2007 and type: get-pssnapin -registered.
There we have it, it’s a Snapin
Now on your OM12 server open the Operations Manager Shell and type: get-module -listavailable
But wait, there is more. Let’s check if there is also a Snapin.
Seems we also have installed the “old” OpsMgr 2007 Snapin.
Commands (Verbs & Nouns)
Let’s start with checking the PowerShell Best-practices for the OM12 Cmdlets and Functions:
When importing a module or Snapin with the verbose parameter, PowerShell checks if unapproved verbs are being used.
More information about Cmdlet Verb Names can be found here: http://msdn.microsoft.com/en-us/library/ms714428.aspx
OpsMgr 2007 had one unapproved verb, the Reject-AgentPending Cmdlet
You can check this yourself by using the import-module "C:\Program Files\System Center Operations Manager 2007\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll" -verbose
Let’s check OM12 for unapproved verbs:
No unapproved verbs for the Commands used in OM12 Seems we have followed our own naming principles this time
Number of OM12 Commands.
We can retrieve the number of OM12 commands by using the next commands: (Get-Command -Module OperationsManager).count
So in OM12 we have 87 Commands to help us manage OM12. We can check the number of Commands for OpsMgr 2007 using PowerShell Remoting from the OM12 Management Server:
Enter-PSSession –ComputerName OpsMgrRMS.stranger.local -Credential (Get-Credential) add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" Set-Location "OperationsManagerMonitoring::" New-ManagementGroupConnection -connectionString:opsmgrrms.stranger.local Set-Location opsmgrrms.stranger.local (get-operationsmanagercommand).count
So OM12 and OpsMgr 2007 have both 87 Commands.
List of OM12 Commands
Name
Add-SCOMAgentlessManagedComputer Approve-SCOMPendingManagement Deny-SCOMPendingManagement Disable-SCOMAgentProxy Disable-SCOMDiscovery Disable-SCOMMonitor Disable-SCOMNotificationSubscription Disable-SCOMRule Enable-SCOMAgentProxy Enable-SCOMDiscovery Enable-SCOMMonitor Enable-SCOMNotificationSubscription Enable-SCOMRule Export-SCManagementPack Export-SCOMEffectiveMonitoringConfiguration Export-SCOMManagementPack Get-SCClass Get-SCDiscovery Get-SCManagementGroupConnection Get-SCManagementPack Get-SCOMAccessLicense Get-SCOMAgent Get-SCOMAgentlessManagedComputer Get-SCOMAgentManagementServerSetting Get-SCOMAlert Get-SCOMAlertHistory Get-SCOMClass Get-SCOMClassInstance Get-SCOMCommand Get-SCOMConnector Get-SCOMDiagnostic Get-SCOMDiscovery Get-SCOMEvent Get-SCOMGatewayManagementServer Get-SCOMGroup Get-SCOMMaintenanceMode Get-SCOMManagementGroupConnection Get-SCOMManagementPack Get-SCOMManagementServer Get-SCOMMonitor Get-SCOMNotificationAction Get-SCOMNotificationEndpoint Get-SCOMNotificationRecipient Get-SCOMNotificationSubscription Get-SCOMOverride Get-SCOMOverrideResult Get-SCOMPendingManagement Get-SCOMRecovery Get-SCOMRelationship Get-SCOMRelationshipInstance Get-SCOMResourcePool Get-SCOMRMSEmulator Get-SCOMRule Get-SCOMRunAsAccount Get-SCOMRunAsProfile Get-SCOMTask Get-SCOMTaskResult Get-SCOMUserRole Get-SCRelationship Get-SCRelationshipInstance Import-SCManagementPack Import-SCOMManagementPack Install-SCOMAgent New-SCManagementGroupConnection New-SCOMManagementGroupConnection New-SCOMResourcePool Remove-SCManagementGroupConnection Remove-SCManagementPack Remove-SCOMAgentlessManagedComputer Remove-SCOMDisabledClassInstance Remove-SCOMManagementGroupConnection Remove-SCOMManagementPack Remove-SCOMResourcePool Remove-SCOMRMSEmulator Set-SCManagementGroupConnection Set-SCOMAgentlessManagedComputer Set-SCOMAgentManagementServerSetting Set-SCOMAlert Set-SCOMMaintenanceMode Set-SCOMManagementGroupConnection Set-SCOMResourcePool Set-SCOMRMSEmulator Set-SCOMRunAsProfile Set-SCOMUserRole Start-SCOMMaintenanceMode Start-SCOMTask Uninstall-SCOMAgent
Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Alias Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Alias Cmdlet Function Cmdlet Cmdlet Alias Cmdlet Cmdlet Cmdlet Cmdlet Alias Alias Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Alias Alias Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Alias Cmdlet Cmdlet Alias Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Alias Alias Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Alias Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet
Add-ConnectorToTier Add-RemotelyManagedComputer Add-RemotelyManagedDevice Add-UserToUserRole Approve-AgentPendingAction Disable-NotificationSubscription Disable-Rule Enable-NotificationSubscription Enable-Rule Export-ManagementPack Get-Agent Get-AgentPendingAction Get-Alert Get-AlertDestination Get-AlertHistory Get-Connector Get-DefaultSetting Get-Diagnostic Get-Discovery Get-Event Get-FailoverManagementServer Get-GatewayManagementServer Get-MaintenanceWindow Get-ManagementGroupConnection Get-ManagementPack Get-ManagementServer Get-Monitor Get-MonitorHierarchy Get-MonitoringClass Get-MonitoringClassProperty Get-MonitoringObject Get-MonitoringObjectGroup Get-MonitoringObjectPath Get-MonitoringObjectProperty Get-NotificationAction Get-NotificationEndpoint Get-NotificationRecipient Get-NotificationSubscription Get-OperationsManagerCommand Get-Override Get-PerformanceCounter Get-PerformanceCounterValue Get-PrimaryManagementServer Get-Recovery Get-RelationshipClass Get-RelationshipObject Get-RemotelyManagedComputer Get-RemotelyManagedDevice Get-ResultantCategoryOverride Get-ResultantRuleOverride Get-ResultantUnitMonitorOverride Get-RootManagementServer Get-Rule Get-RunAsAccount Get-State Get-Task Get-TaskResult Get-Tier Get-UserRole Install-Agent Install-AgentByName Install-ManagementPack New-CustomMonitoringObject New-DeviceDiscoveryConfiguration New-LdapQueryDiscoveryCriteria New-MaintenanceWindow New-ManagementGroupConnection New-MonitoringPropertyValuePair New-Tier New-WindowsDiscoveryConfiguration Reject-AgentPendingAction Remove-ConnectorFromTier Remove-DisabledMonitoringObject Remove-ManagementGroupConnection Remove-RemotelyManagedComputer Remove-RemotelyManagedDevice Remove-Tier Resolve-Alert Set-AlertDestination Set-DefaultSetting Set-MaintenanceWindow Set-ManagementServer Set-ProxyAgent Start-Discovery Start-Task Uninstall-Agent Uninstall-ManagementPack
Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet Cmdlet
Some of the Commands I highlighted are some of the aliases being used in OM12.
You can get more information on Aliases by using the Get-Command -module operationsmanager –CommandType Alias
I guess these Aliases are created to give the OM12 Commands a consistent SCOM* Naming Convention.
And for the current OM12 Commands we also see we have created a Function Get-SCOMCommand. So how is that Get-SCOMCommand Function created?
First we are going into the Function drive.
CD Function:
Next we are using the Get-Content Cmdlet to look into the Get-SCOMCommand function.
Get-Content Get-SCOMCommand
Ok, we just created a function which uses the Get-Command –Module OperationsManager to list all SCOM Commands
This is it for now, but I’ll try to post more about the new OM12 Commands.
Today I wanted to have a look at the Exchange 2010 Management Pack files, but I did not had access to an OpsMgr 2007 environment and only had my laptop with Windows 7 running with me. So I started to download the Exchange 2010 MP from the Microsoft PinPoint Website.
After the download had finished I tried to install the Exchange2010ManagementPackForOpsMgr2007-EN-x64.msi file but it failed with the next error.
Although you could argue that Windows 7 is a higher OS than Windows Server 2003 I opened Orca to have a look at the MSI Installer. But than I remembered you can easily extract files from a MSI using the next commands:
msiexec /a Exchange2010ManagementPackForOpsMgr2007-EN-x64.msi /qb TARGETDIR="c:\temp\exchange2010"
And there they where, the MP files I was looking for
I was investigating an issue with OpsMgr Agents who where stuck in Maintenance Mode. A big help was this article from David Dixon.
We managed to solve the issue but we also wanted to know what caused the issue and I investigated if the RMS HealthService was put in Maintenance Mode accidentally. By the way, it is not a good thing to put the RMS in Maintenance Mode!
Update 2: I got an email from one of my co-workers Marek Tyszkiewicz telling me he made an enhancement to my SQL query to find out if the RMS HealthService was put in Maintenance Mode:
-- Find if RMS is put in MM -- Author: Stefan Stranger -- Version 0.3 -- Remark: Added (NOLOCK) to query. Thanks to Jeremy Pavleck. -- Remark: No need to specify RMS server name. Thanks to Marek Tyszkiewicz-- Date: 20-04-2011 USE OperationsManagerDWSELECT ManagedEntity.DisplayName, MaintenanceModeHistory.* FROM ManagedEntity WITH (NOLOCK)INNER JOIN MaintenanceMode ON ManagedEntity.ManagedEntityRowId = MaintenanceMode.ManagedEntityRowId INNER JOIN MaintenanceModeHistory ON MaintenanceMode.MaintenanceModeRowId = MaintenanceModeHistory.MaintenanceModeRowId WHERE (ManagedEntity.DisplayName in (SELECT DISTINCT METarget.DisplayNameFROM vManagedEntity MESourceINNER JOIN vRelationship R ON R.SourceManagedEntityRowId = MESource.ManagedEntityRowIdINNER JOIN ManagedEntity METarget ON R.TargetManagedEntityRowId = METarget.ManagedEntityRowIdWHERE MESource.FullName = 'Microsoft.SystemCenter.RootManagementServerComputersGroup'))
Have fun pointing your finger ;-)
This week I got some questions about Multihoming agents. As you know, a multihomed architecture is based on the concept of an agent reporting to two (or more) management groups. But first I wanted to know how I could see if an agent was a multihomed agent and I used PowerShell to look into the registry of an agent for the ManagementGroup information.
dir "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups\" ` | Format-Table @{Label="ManagementGroup";Expression={$_.PSChildName}} –aut
Is this case I used PowerShell Remoting to connect to another Agent in my OpsMgr demo environment to collect the Management Group information.
As you see I don’t have a multihomed agent in my demo environment
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:
using System; using System.Text; using Microsoft.EnterpriseManagement; using Microsoft.EnterpriseManagement.Configuration; using Microsoft.EnterpriseManagement.ConnectorFramework; using Microsoft.EnterpriseManagement.Monitoring; using Microsoft.EnterpriseManagement.Monitoring.Security; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Xml; using System.Security; using Microsoft.EnterpriseManagement.Administration; using NConsoler; //http://nconsoler.csharpus.com/ namespace OpsMgrApproveCredentialForDistribution { class Program { static void Main(string[] args) { //NConsoler Consolery.Run(typeof(Program), args); } [Action] public static void DoWork( [Required(Description="Enter RMS Server name")] string RMS, [Required(Description="Enter RunAs Account Name")] string RunAsAccount, [Required(Description = "Enter FQDN OpsMgr Agent\n" + "\nExample: AddToDistList.exe opsmgrrms.contoso.com om_sql_mon opsmgragent.contoso.com" + "\nAdding a computer to the Distribution list on a RunAs Account application for OpsMgr 2007" + "\nemailname@hotmail.com\n" + "\nProvided 'AS IS' without warranty of any kind")] string OpsMgrAgent) { Console.WriteLine("OpsMgrApproveCredentialForDistribution - Version 1.3 - Compiled March 5, 2011"); Console.WriteLine("http://blogs.technet.com/stefan_stranger"); // Connect to the sdk service on the RMS //ManagementGroup localManagementGroup = new ManagementGroup(strRMS); ManagementGroup localManagementGroup = ConnectMG(RMS); if (localManagementGroup == null) { Console.WriteLine("Failed to connect to Root Management Server " + RMS); } else { MonitoringSecureDataCriteria runAsAccountCriteria; ReadOnlyCollection<MonitoringSecureData> runAsAccounts; Console.WriteLine("RunAs Account Username:" + RunAsAccount); runAsAccountCriteria = new MonitoringSecureDataCriteria("UserName LIKE " + "'" + RunAsAccount + "'"); runAsAccounts = localManagementGroup.GetMonitoringSecureData(runAsAccountCriteria); if (runAsAccounts.Count == 0) throw new InvalidOperationException("Error! RunAs Account not found: " + RunAsAccount); MonitoringSecureData account = runAsAccounts[0]; List<MonitoringObject> list = new List<MonitoringObject>(); // Fully qualified name of the agent-managed computer. ManagementGroupAdministration admin = localManagementGroup.GetAdministration(); string query = "Name = '" + OpsMgrAgent + "'"; AgentManagedComputerCriteria agentCriteria = new AgentManagedComputerCriteria(query); ReadOnlyCollection<AgentManagedComputer> agents = admin.GetAgentManagedComputers(agentCriteria); if (agents.Count != 1) throw new InvalidOperationException("Error! OpsMgr Agent not found: " + OpsMgrAgent); //Add OpsMgr Agent to list list.Add(agents[0].HostedHealthService); localManagementGroup.ApproveCredentialForDistribution((ISecuredData)account, list); Console.WriteLine("OpsMgr Agent " + OpsMgrAgent + " added to distribution list"); } } private static ManagementGroup ConnectMG() { throw new NotImplementedException(); } //Connect to SDK Service on Root Management Server private static ManagementGroup ConnectMG(String RMS) { Console.WriteLine("Connect to Root Management Server:" + RMS); try { ManagementGroupConnectionSettings connectionSettings = new ManagementGroupConnectionSettings(RMS); ManagementGroup localManagementGroup = ManagementGroup.Connect(connectionSettings); if (!localManagementGroup.IsConnected) { throw new InvalidOperationException("Not connected to an SDK Service."); } Console.WriteLine("Connected to Management Group {0}", localManagementGroup.Name); return localManagementGroup; } catch (Exception exception) { Console.WriteLine("\nConnection failed. " + exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); return null; } } return null; } } }
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:
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.
This week I had a conversation with a customer who wanted to offer their admins OpsMgr Web Consoles instead of the “normal” fat-client OpsMgr Consoles. Most customers think that the Web Console would have less impact on the RSM as the “normal” fat-client.
But when we look in the Operations Manager 2007 Performance and Scalability Guide and look at what impacts the performance of the RMS we read:
Factors that influence the load on the root management server include:
And because the Web Console is a SDK Client just like the “normal” OpsMgr Console, you could conclude that the Web Console has the same impact on the RMS as the “normal” OpsMgr Console. But what happens when you use the Web Console in OpsMgr 2007 R2? The R2 Web Console opens the connection, then caches the connection instance in the Session on the server and reuses for all subsequent requests. The connection is not closed explicitly. As said earlier the Web Console uses the same API calls as the “normal” OpsMgr Console.
The major difference between the Web Console and the OpsMgr Console is the OpsMgr Console local cache. So you could say the Web Console has more impact on the RMS just because it queries the RMS each time that data is needed, versus the OpsMgr Console looking in the local cache first.
You can configure the Web Console settings via the web.config file. My colleague Micheal Pearson has written a blogarticle about which settings can be configured. You could limit the rows in your Alert Views or State views, but this is done on the Web Server hosting the OpsMgr Web Console. Still all data is queried via the SDK on the databases. The web.config settings controls the rendering, that is how much data is transferred from the web server to the client.
Hope this clarifies the difference between the Web Console and OpsMgr Console and their impact on the RMS. I want to thank Michael Pearson and Alexander Netrebchenko for helping with topic.
Grab this badge here!
Last year I participated for the first time in the Scripting Games and it was a great experience because I was the lucky winner of PowerShell ASP software from n/Software. But now it’s your chance to participate in the 2011 Scripting Games.
The 2011 Scripting Games begin on April 4, 2011 and run through April 15, 2011. What is the Scripting Games, you may ask? Well simply put, the Scripting Games are the premier learning event of the year for IT Pro’s and others who wish to master Windows PowerShell. Comprising 10 events, a registered contestant has seven days to create a solution to a scenario driven problem and post their code to a MVP maintained script repository for evaluation by a panel of internationally recognized judges. Daily leaderboards and prize drawings help to maintain the suspense throughout the two-week international event.
During the 2011 Scripting Games hundreds of contestants will submit thousands of scripts that will be reviewed by dozens of judges. Hundreds of thousands of spectators from all around the world will view the games themselves. Last year, participants from more than 100 countries participated in the Scripting Games. With an emphasis on real world scripting scenarios and problems, the scripts will be of immediate value to both the participants and to the spectators.
Preparation for the 2011 Scripting Games is already underway, with a learning guide, step-by-step tutorials, videos and other resources being generated on a daily basis. The 2011 Scripting Games all in one page is the portal for the games themselves. The 2010 Scripting Games all in one page is still available, as are the events from the 2009 Scripting Games.
Some weeks ago I got a question from Marnix Wolf asking if it’s possible to retrieve Company Knowledge for a monitor or rule and sent that as email. And after an evening playing around with PowerShell I created a PowerShell script that could do exactly that.
Pre-requisites:
Background info:
I hope you know you can add your own Company Knowledge for a rule or monitor. Administrators can add their own knowledge to rules and monitors to expand the troubleshooting information and provide company-specific information for operators, which is known as company knowledge. Administrators can use company knowledge to document any overrides implemented for a monitor or rule, along with the explanation for the customization and any other information that might be useful.
Operations Manager stores company knowledge in a management pack. Sealed management packs cannot be modified, so Operations Manager saves customizations such as company knowledge in a custom management pack. By default, Operations Manager saves all customizations to the Default Management Pack. As a best practice, you should instead create a separate management pack for each sealed management pack you want to customize. More info about adding Company Knowledge can be found here. For the pre-requisites you can take a look at this blogpost on the MOMTeam blogsite.
Now we saved the Company Knowledge for the monitor and rule we can extract this info from the Management Pack. It’s also somewhere in the database but extracting it from the Management Pack is the easiest way IMO.
These are the high-level steps that need to be executed in the PowerShell script:
Step 1. Find Monitor or Rule for Alert.
#Error Handling #This is because when there is no monitor found in the FindMonitorForAlert Function #the script needs to continue. $ErrorActionPreference="SilentlyContinue" $Error.psbase.clear()
Function Initialize { ## Check for OpsMgr shell if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null) { Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red LoadSnapin("localhost") } } Function LoadSnapin($RMS) { add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"; set-location "OperationsManagerMonitoring::"; new-managementGroupConnection -ConnectionString:$RMS; set-location $RMS; } Function FindMonitorOrRuleForAlert($AlertName) { #Find an alert with resolution state new $alert = get-alert | where {$_.Name -eq "$AlertName"} #Check if Alert is available if ($alert) { #Find monitor for Alert. $monitorname = (get-monitor $alert.monitoringruleid).Name
#Check if Monitor is found if ($monitorname) { Write-Host "Monitor Found" return $monitorname } else { #Call FindRuleForAlert FindRuleForAlert $AlertName } } else { Write-Host "No Alert found" } } Function FindRuleForAlert($AlertName) { $alert = get-alert | where {$_.Name -eq "$AlertName"} #Find rule for Alert. $rulename = (get-rule $alert.monitoringruleid).Name Write-Host "Rule Found" return $rulename } #Main Initialize FindMonitorOrRuleForAlert "Data Access Service - Windows Service" FindMonitorOrRuleForAlert "Root Management Server Unavailable."
When we run the above PowerShell script we find the Monitor or Rule name for the alerts “Data Access Service – Windows Service” and “Root Manager Server Unavailable.
We know have a way to find the Monitor or Rule name for an alert.
Step 2. Export Management where Company Knowledge is saved.
<# In this part of the script we are going to export the Management Packs and save it in the User's temp folder #>
Function Initialize { ## Check for OpsMgr shell if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null) { Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red LoadSnapin("localhost") } } Function LoadSnapin($RMS) { add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"; set-location "OperationsManagerMonitoring::"; new-managementGroupConnection -ConnectionString:$RMS; set-location $RMS; }
Function ExportMP($MPname, $mpexportfolder) { #Get Management where Company Knowledge is saved. Must be know in advance. get-managementpack | where {$_.Name -eq $MPName} | export-managementpack -path $mpexportfolder Write-Host "MP exported to xml" }
#Main
Initialize
ExportMP -MPname "Stefan.Company.Knowledge.Test.MP" -mpexportfolder ($env:TEMP)
We now exported the Management Pack where we saved the Company Knowledge to the users temp directory.
Step 3. Parse Company Knowledge for Monitor from exported XML MP.
<# In this part of the script we are parse the Company Knowledge for the Monitor or Rule #>
#Variables $monitorname = "Microsoft.Windows.Server.AD.Domain.AvailRollupMonitor"
Function ParseCK($monitor,$mpexportfolder,$MPName) { $xml = [xml](Get-Content $mpexportfolder"\"$MPname".xml") #MonitorName $ElementID = "'"+ "$Monitor" + "'" $KnowledgeArticle = [xml](Select-Xml -xml $xml -xpath "//KnowledgeArticle[contains(@ElementID, $ElementID)]") $myarray = $KnowledgeArticle.MamlContent.section $myarray | Format-Table @{Label="Title";Expression={$_.title}}, @{Label="Text";Expression={$_.para}} -aut Write-Host "finished" } #Main Initialize
ParseCK -monitor $monitorname -mpexportfolder ($env:TEMP) -MPName "Stefan.Company.Knowledge.Test.MP"
Or for the Rule:
Step 4. Email Company Knowledge
In PowerShell 2.0 there is a new cmdlet Send-MailMessage, but I’m going to use the Net.Mail.MailMessage .Net class because my smtp server needs authentication.
<# In this part of the script we are emailing the Company Knowledge #>
#Body $body = @" <h1>Knowledge Article</h1>
<h2>Summary</h2>
<h2>Configuration</h2>
<h2>Causes</h2>
<h2>Resolutions</h2>
<h2>Additional Information</h2>
<h2>External Knowledge Sources</h2> "@
# Create mail and set priority $mail = new-object Net.Mail.MailMessage $mail.Priority = [System.Net.Mail.MailPriority]::High
# Create from, to, and bcc $mail.From = opsmgr@stranger.local $mail.To.Add("username@hotmail.com") $mail.CC.Add("username@microsoft.com") $mail.BCC.Add(username@stranger.local)
# Create the message $mail.Subject = "OpsMgr email with Company Knowledge" + " (" + [System.DateTime]::Now.ToString("yyyy-MM-dd HH:mm") + ")" $mail.Body = $body $mail.IsBodyHtml = $true
# Set SMTP Server and create SMTP Client $smtp = new-object Net.Mail.SmtpClient $smtp.Host = "mail.stranger.local" $smtp.Port = "25" $smtp.EnableSsl = $false $smtp.Credentials = New-Object System.Net.NetworkCredential(stefan@stranger.local, P@ssw0rd);
# Send message try { $smtp.Send($mail) } catch { "Exception caught: {0}" -f $Error[0] }
Ok now we only have to put all the separate parts together
<# Pulling OpsMgr Company Knowledge from Management Pack and send it to email. This script will find the monitor or rule for a selected alert and pull the Company Knowledge for this monitor or rule from the exported Management Pack. Tested on: - OpsMgr 2007 R2 - PowerShell version 2.0 Remark: All the Company Knowledge should be saved in ONE Management Pack Author: Stefan Stranger Date: 17-02-2011 #>
param($AlertName=(Read-Host "Please Enter Alert Name"),$emailto=(Read-Host "Please Enter email address"))
#Variables: $global:mpname = "" $global:rmsname = "opsmgrrms.stranger.local" $global:mpname = "Stefan.Company.Knowledge.Test.MP" $currentpath = pwd
Function Initialize { ## Check for OpsMgr shell if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null) { Write-Host "Load OpsMgr Snapin if not loaded" -foregroundcolor red LoadSnapin("$rmsname") } } Function LoadSnapin($rmsname) { add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"; set-location "OperationsManagerMonitoring::"; new-managementGroupConnection -ConnectionString:$rmsname; set-location $rmsname; }
Function FindRuleForAlert($AlertName) { $alert = get-alert | where {$_.Name -like "$AlertName"} $monitoringruleid = ($alert | select MonitoringRuleID -first 1).MonitoringRuleId.Guid #Find rule for Alert. $rulename = (get-rule $monitoringruleid).Name Write-Host "Rule Found" return $global:monitororrulename = $rulename } Function FindMonitorOrRuleForAlert($AlertName) { #Find an alert with resolution state new $alert = get-alert | where {$_.Name -like "$AlertName"} #Check if Alert is available if ($alert) { $monitoringruleid = ($alert | select MonitoringRuleID -first 1).MonitoringRuleId.Guid #Find monitor for Alert. $monitorname = (get-monitor $monitoringruleid).Name
#Check if Monitor is found if ($monitorname) { Write-Host "Monitor Found" return $global:monitororrulename = $monitorname } else { #Call FindRuleForAlert FindRuleForAlert $AlertName } } else { Write-Host "No Alert found" break } }
#Step 2. Export Management where Company Knowledge is saved. <# In this part of the script we are going to export the Management Packs and save it in the User's temp folder #>
#Step 3. Parse Company Knowledge for Monitor from exported XML MP. <# In this part of the script we are parse the Company Knowledge for the Monitor or Rule #>
Function ParseCK($monitororrulename,$mpexportfolder,$MPName) { $xml = [xml](Get-Content $mpexportfolder"\"$MPname".xml") $ElementID = "'"+ "$monitororrulename" + "'" $KnowledgeArticle = [xml](Select-Xml -xml $xml -xpath "//KnowledgeArticle[contains(@ElementID, $ElementID)]") $global:myarray = $KnowledgeArticle.MamlContent.section #$myarray | Format-Table @{Label="Title";Expression={$_.title}}, @{Label="Text";Expression={$_.para}} -aut Write-Host "Parsed Company Knowledge" }
#Step 4. Email Company Knowledge <# In this part of the script we are emailing the Company Knowledge #>
$Summary = ($myarray | where {$_.Title -eq "Summary"}).para $Configuration = ($myarray | where {$_.Title -eq "Configuration"}).para $Causes = ($myarray | where {$_.Title -eq "Causes"}).para $Resolutions = ($myarray | where {$_.Title -eq "Resolutions"}).para $Additional = ($myarray | where {$_.Title -eq "Additional"}).para $External = ($myarray | where {$_.Title -eq "External"}).para
<h2>Summary</h2> <p>$Summary</P> <h2>Configuration</h2> <p>$Configuration</P> <h2>Causes</h2> <p>$Causes</P> <h2>Resolutions</h2> <p>$Resolutions</P> <h2>Additional Information</h2> <p></P> <h2>External Knowledge Sources</h2> <p>$External</P> "@
Function EmailCK($emailto) {
# Create from, to, and bcc $mail.From = "opsmgr@stranger.local" $mail.To.Add($emailto) $mail.CC.Add("username@microsoft.com") $mail.BCC.Add(username@stranger.local)
# Set SMTP Server and create SMTP Client $smtp = new-object Net.Mail.SmtpClient $smtp.Host = "mail.stranger.local" $smtp.Port = "25" $smtp.EnableSsl = $false $smtp.Credentials = New-Object System.Net.NetworkCredential("username@stranger.nl", P@ssword);
# Send message try { $smtp.Send($mail) Write-Host "Email is sent" } catch { "Exception caught: {0}" -f $Error[0] } }
#Step 5. Clean up <# In this part of the script we are cleaning up. Remove the exported MP XML file. #>
Function CleanUp($MPname) { remove-item ($env:TEMP+"\"+$MPname+".xml") Write-Host "Remove MP XML File" remove-pssnapin -name "Microsoft.EnterpriseManagement.OperationsManager.Client" cd $currentpath $AlertName = ""
}
#Main Initialize
FindMonitorOrRuleForAlert $AlertName
ExportMP -MPname $mpname -mpexportfolder ($env:TEMP)
ParseCK -monitor $monitororrulename -mpexportfolder ($env:TEMP) -MPName $mpname
EmailCK -emailto $emailto
CleanUp -MPname $mpname
Have fun!F