Skip to content
adatum
  •  SCOM Web API
  • About adatum
Operations Manager

Schedule maintenance mode for group (easy)

  • 08/06/201508/06/2015
  • by Martin Ehrnst

One of the most annoying things whit System Center Operations Manager is the lack of maintenance mode scheduling built in. (You have some options, with Orchestrator, SCCM etc). One thing I personally struggle with, is to maintenance mode every server during Windows Update since we use WSUS for patching and not SCCM. but that’s not the purpose of this post.

In this post, i will guide you through how you can schedule maintenance mode for a (SCOM) group of computers with tools you already have installed – Powershell and Task Scheduler. In our environment we have some Citrix XenApp servers which are scheduled to reboot every night. Since they boot at the exact same time they are easier to maintenance mode than all other servers that boot randomly during updates.

This post will guide you through the following.

  • Create a dynamic group containing the servers (I will use OU in this example, but you are free to use what ever you like)
  • The Powershell script to run against OpsMgr
  • Configuration of the Scheduled task.

Creating the dynamic group

Under Authoring in your console, create a new group. I have called mine “Citrix Servers” stored in a custom management pack. Under dynamic members you will have to create a formula to populate the group members. Her you can choose the solution that fit your needs, but I will be using OU, as our Citrix servers are stored in their own OU.

Dynamic group based on OU
Dynamic group based on OU

( Object is Windows Computer AND ( Organizational Unit Matches wildcard *OU=Citrix* ) AND True )

If you have some servers in the same OU, that you do not want included in this group. You can add them in the “exculded members” pane. Once your group is created, allow for the “System Center Minute” to complete, and if everything is OK, you should see your servers.

TIP: Finding a coumputers OU. Check its Properties under Windows Computers

 

The Powershell script and task

Since were not allowed to start maintenance mode ahead in time, we have to rely on our favorite automation tool called Powershell. In the OpsMgr module there is a Cmdlet, Start-ScomMaintenanceMode, which have a time variable.

Start-MaintenanceMode on technet

param($ManagementServer, $GroupName, $Minutes, $Reason, $Comment)

Import-Module OperationsManager #Import the opsmgr module
New-SCOMManagementGroupConnection -ComputerName $ManagementServer #connect to MS
$SCOMGroup = Get-SCOMGroup | where {$_.DisplayName -like "$GroupName"} #Get the scom group to maintenance
$Time = ((Get-Date)).AddMinutes(($Minutes)) #get time and date. Add minutes. This will be how many minutes object is in maintenance mode
Start-SCOMMaintenanceMode -Instance $SCOMGroup -EndTime $Time -Reason "$Reason" -Comment $Comment
-Command "z:\path\script.ps1 - ManagementServer 'ManagementServerFQDN' -GroupName 'GroupDisplayName' -Minutes 'XX' -Reason 'YourReason' -Comment 'YourCommentHere' ; exit $LASTEXITCODE"

Creating the task

Start by creating a new Scheduled task. Under triggers, set the time and all other configuration you will need.

Under ‘actions’ browse to system32 and add powershell as the program to run. (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) Under arguments, edit to fit your needs and paste in the above.

Reasons accepted

— PlannedOther
— UnplannedOther
— PlannedHardwareMaintenance
— UnplannedHardwareMaintenance
— PlannedHardwareInstallation
— UnplannedHardwareInstallation
— PlannedOperatingSystemReconfiguration
— UnplannedOperatingSystemReconfiguration
— PlannedApplicationMaintenance
— ApplicationInstallation
— ApplicationUnresponsive
— ApplicationUnstable
— SecurityIssue
— LossOfNetworkConnectivity

Verify that everything works as expected

Event Viewer

mainteventID

Operations Console

MaintFinish

 

Hope this get you on your way to schedule maintenance mode. When I decide to use SCCM to do our patching, or we come up with another idea, I will let you know.

As always – complete this in your test environment to confirm it’s working.
PS: Operations Manager 2016 will have scheduling built in.

Share this:

  • LinkedIn
  • Twitter
Operations Manager

First look at SquaredUp’s new Visio plugin

  • 30/04/2015
  • by Martin Ehrnst

A short while ago i implemented SquaredUp – a dashboard solution for OpsMgr in the company i work for. A few days ago, they released a new version (2.1) which includes a new Visio plugin. In short, this plugin allows you to add Monitored Objects to your Visio diagram, and show it’s health state the way you like it.

In this short write up i will show you how i created one of our wall monitors. But the first thing you need is SquaredUp installed (download and test :).

In MS Visio, start out with a basic diagram, or one of your existing ones. This is my start.

SUapp

Next, you will have to add data to your shapes. SquaredUp relies on Object ID from OpsMgr. You can find this, either through Powershell or maybe it is easier to navigate to the object in Squared Up, since thats where you already are. Label: ScomID, value: <yourscomid>
Repeat this for all your objects you want to display.
(PS: if you have all your objects in a group, you can export group members from SquaredUp, and import to visio)

SUShapeData

After all this is done. Export your Visio drawing in to .SVG. Now you create a new dashboard in SU with a Visio section. You can choose to color replace, or add an icon (which you also could with image plugin)
suvisio suvisiocolor

 

After all is done. This is how our dashboard look like. Exchange all green

suappdash

 

The possibilities are “endless” this is how our wall monitor look like. The green shade represent the overall group state.

SUCloud

 

 

Share this:

  • LinkedIn
  • Twitter
MPAuthoring

Creating seed discovery with Silect MP Author

  • 21/04/201519/05/2015
  • by Martin Ehrnst

FYI: This is now a built in feature in MPAuthor SP4


 

As a System Center Operations Manager Engineer (or what ever your title is) you are probably some what familiar with developing your own management packs, and if not, you most likely will end up in a situation where a colleague or a client want you to monitor his or hers custom developed application, or your environment requires you to do some MP development. There are many solutions out there to do the dirty work for you, and they are all good in their own ways. You can use the Authoring functions in your OpsMgr console (basic stuff available), Developers can use Visual Studio etc. My personal favorite is MP Author from Silect. This software is GUI oriented and will help you create management packs for any SW you want. Although, it has it limitations, it is also possible to edit the XML created through it’s wizard.

One of the things that is not possible to do in MP Author’s GUI is to create a seed class/discovery. If you’re not familiar with this concept there are many good articles available on the internet, but in short terms you create a class and discovery to find the smallest bit of your application (ie. registry key) and then target your other discoveries to the seed class.

In my case i had to develop a management pack that was print server related. I created a new target and discovery in MPAutor which would run against Windows Computer class. This discovery runs a WMI query for Print and Document services.

SELECT Name FROM Win32_ServerFeature WHERE ID=261

261 is the ID for Print and Document Services role installed (in this case) on all servers we would like to monitor.

demoappseed
seed discovery

Now, our seed discovery is created, and it is time to create discovery for your application it self.

I create a new registry target to find the “rest” of my application, base class now is Windows Local Application

demoappfulldiscovery demoreg

 

 

You could think our full discovery is finished now, but as you can see, our second discovery is targeted Windows Computer class.

demoappbaseclass

I wan’t this to target all computers that are running this application, “AdatumDemoApp.Seed” time for some .XML editing. Click “Edit XML” for your full discovery, and change this line:

Target="Windows!Microsoft.Windows.Computer

to

Target="AdatumDemoApp.Seed"

Wich is the name of the target you created (not the discovery name)
Look your discovery is now targeted your seed class. Time to import in your demo environment and see what’s not working 🙂

discoveryOK

 

 

Share this:

  • LinkedIn
  • Twitter
Operations Manager

HealthServiceStore.edb file growth

  • 25/03/201508/04/2015
  • by Martin Ehrnst

A while back i got an alert that system drive on one of our monitored servers was full. When examining what was consuming disk space I noticed that HealthServiceStore.edb, located in the agent’s Health Service State folder was way to large.

HealthServiceStore.edb is where the result of every workflow that runs on this agent is stored and sent to your Management Server(s). An agent running a lot of performance counters (Exchange, SQL etc) will probably have a larger database file than your average file server.

At first, i tried to flush the agents cache wich did not work. The next thing i tried was to run the “online store maintenance” task from OpsMgr console, this task will run a de-fragmentation of the database file.
onli

You can follow the result in the event log, HealthService (7404) Health Service Store: Online defragmentation is beginning a full pass on database ‘<C:\Program Files\Microsoft Monitoring Agent\Agent\Health Service State\Health Service Store\HealthServiceStore.edb>’.

Did this work? No, my database file was still huge.
The next thing to do, is to perform a “Dirty Defrag” on the DB file. To do this,

  • open your favorite shell and navigate to C:\Program Files\Microsoft Monitoring Agent\Agent\Health Service State\Health Service Store
  • Stop Healthservice.exe (Microsoft Monitoring Agent)
  • Run esentutl /r edb (recovery mode)
  • Start defragmentation by running esentutl /d HealthServiceStore.edb

esentutl

Your healthservicestore.edb should now have a normal size.

Do you have anything to include, please comment.

Share this:

  • LinkedIn
  • Twitter
Operations Manager

Export overrides to CSV, XML & HTML

  • 23/03/201519/08/2015
  • by Martin Ehrnst

To accomplish an internal goal, this script has been updated to accept parameters.

New version is available here and can be used like this Export-Overrides -managementserver -path -type -suffix

**

Originally, this script was published by Daniele Muscetta and Pete Zerger over at SystemCenterCentral.com. I adopted Dieter Wijckmans version to fit our needs.

Basicly we all need to find our way to document how our OpsMgr environment is configured. We all have our ways (some not) and we first started out using exporting our MP’s to excel with MPViewer where we manually added colours to rules that where disabled. That worked good for us, and we still use this method when we import management packs the first time, but maintaining these documents can be tough. For some time i have exported all unsealed management packs used for overrides to .csv files, and used those to track changes. Today i was asked if i could make them easier to read. Therefor i took the script we have been using (credits in top post) and modified it to include XML, CSV and HTML exports. With the HTML we are able to easily read the overrides, we can use CSV to edit in excel and XML export (you all know this) can be imported back to OpsMgr in case you need it.

In order to get this script running. You have to set your export path, enable or disable export types and define a suffix for your overrides management pack. All this is done in the “configuration area”

#====================================================================================================================
# AUTHOR:	DieterWijckmans (Dieter -Wijckmans -inovativ - be)
# DATE:		03/08/2012
# Name:		Export-Overrides2012.PS1
# Version:	1.2
#
# MODIFIED BY: MartinEhrnst (m a r t i n - e h r n s t - n o)
# MODIFY DATE: 18/03/2015
#
# COMMENT:	Export all your overrides to a CSV, XML & HTML files to keep for your reference.
#			Based on script of DanieleMuscetta and PeteZerger
#			http://www.systemcentercentral.com/BlogDetails/tabid/143/IndexID/78323/Default.aspx
#           
# 
# Usage:	Change your Management pack suffix, export location and Export types YES/NO.
#           Run script manually or with you favorite automation tool
#DontHassleTheCode
#
#=====================================================================================================================

#############################################################
################# CONFIGURATION AREA ########################
#Set export location
$locationroot = "PATH"
#Define your Overrides suffix
$MPSuffix = "SUFFIX"
#export methods
$CSV = "NO" #CSV export to use in excel etc.
$HTML = "YES" #HTML for easier readability
$XML = "YES" #enable if you want to import back toOpsMgr
################ END CONFIGURATION AREA ######################
##############################################################

#HTML OUTPUT STYLING
$Header = @""@ ##This will read out your server name. Run from a management server. $objCompSys = Get-WmiObject win32_computersystem $inputScomMS = $objCompSys.name #Initializing the Ops Mgr 2012 Powershell provider# Import-Module -Name "OperationsManager" New-SCManagementGroupConnection -ComputerName $inputScomMS #Error handling setup $error.clear() $erroractionpreference = "SilentlyContinue" $thisScript = $myInvocation.MyCommand.Path $scriptRoot = Split-Path(Resolve-Path $thisScript) $errorLogFile = Join-Path $scriptRoot "error.log" if (Test-Path $errorLogFile) {Remove-Item $errorLogFile -Force} #Define the backup location #Get date $Backupdatetemp = Get-Date $Backupdatetemplocal = ($Backupdatetemp).tolocaltime() $Backupdate = $Backupdatetemplocal.ToShortDateString() $strBackupdate = $Backupdate.ToString() #Define backup location if((test-path $locationroot) -eq $false) { mkdir $locationroot } $locationfolder = $strbackupdate -Replace "/","-" $location = $locationroot + $locationfolder + "\" new-item "$location" -type directory -force #Delete backup location older than 15 days #To make sure our disk will not be cluttered with old backups we'll keep 15 days of backup locations. $Retentionperiod = "15" $folders = dir $locationroot echo $folders $now = [System.DateTime]::Now $old = $now.AddDays("-$Retentionperiod") foreach($folder in $folders) { if($folder.CreationTime -lt $old) { Remove-Item $folder.FullName -recurse } } #gets all UNSEALED MAnagement Packs with your defined suffix $mps = get-SCOMmanagementpack | where {$_.Sealed -eq $false -and $_.DisplayName -like "*$MPsuffix"} #loops thru them foreach ($mp in $mps) { $mpname = $mp.name Write-Host "Exporting Overrides info for Management Pack: $mpname" #array to hold all overrides for this MP $MPRows = @() #Gets the actual override objects $overrides = $mp.GetOverrides() #loops thru those overrides in order to extract information from them foreach ($override in $overrides) { #Prepares an object to hold the result $obj = new-object System.Management.Automation.PSObject #clear up variables from previous cycles. $overrideName = $null $overrideProperty = $null $overrideValue = $null $overrideContext = $null $overrideContextInstance = $null $overrideRuleMonitor = $null # give proper values to variables for this cycle. this is what we can then output. $overrideName = $override.Name $overrideProperty = $override.Property $overrideValue = $override.Value trap { $overrideContext = ""; continue } $overrideContext = $override.Context.GetElement().DisplayName trap { $overrideContextInstance = ""; continue } $overrideContextInstance = (Get-SCOMMonitoringObject -Id $override.ContextInstance).DisplayName if ($override.Monitor -ne $null){ $overrideRuleMonitor = $override.Monitor.GetElement().DisplayName } elseif ($override.Discovery -ne $null){ $overrideRuleMonitor = $override.Discovery.GetElement().DisplayName } else { $overrideRuleMonitor = $override.Rule.GetElement().DisplayName } #fills the current object with those properties $obj = $obj | add-member -membertype NoteProperty -name overrideName -value $overrideName -passthru $obj = $obj | add-member -membertype NoteProperty -name overrideProperty -value $overrideProperty -passthru $obj = $obj | add-member -membertype NoteProperty -name overrideValue -value $overrideValue -passthru $obj = $obj | add-member -membertype NoteProperty -name overrideContext -value $overrideContext -passthru $obj = $obj | add-member -membertype NoteProperty -name overrideContextInstance -value $overrideContextInstance -passthru $obj = $obj | add-member -membertype NoteProperty -name overrideRuleMonitor -value $overrideRuleMonitor -passthru #adds this current override to the array $MPRows = $MPRows + $obj } #FILE EXPORT - SEE CONFIGURATION AREA #CSV if ($csv -eq "YES"){ $filename = $location + $mp.name + ".csv" $MPRows | Export-Csv $filename } #XML see configuration if ($XML -eq "YES"){ Export-SCOMManagementPack -ManagementPack $mps -Path $location } #HTML see configuration $filename = $location + $mp.name + ".html" if ($HTML -eq "YES"){ $MPRows | ConvertTo-Html -Title "Overrides For $mp" -Head $Header | Out-File $filename } }

 

Share this:

  • LinkedIn
  • Twitter

Posts navigation

1 … 17 18 19

Top Posts & Pages

  • Azure AD authentication in Azure Functions
  • Creating Azure AD Application using Powershell
  • Multi subscription deployment with DevOps and Azure Lighthouse
  • Script to add SCOM agent management group
  • Azure Lighthouse why is it so important
  • Resource health through Azure Rest API
  • SCOM Alerts to Microsoft Teams and Mattermost
  • Remediate Azure Policy with PowerShell
  • Using Azure pipelines to deploy ARM templates
  • Schedule maintenance mode for group (easy)

Tags

agent announcements api ARM authoring Automation Azure AzureAD AzureFunctions AzureLighthouse AzureMonitor AzureSpringClean Bicep Community CSP database EventGrid ExpertsLive ExpertsLiveEU IaC Infrastructure as code Integrations LogAnalytics management pack monitoring MSIgnite MSIgnite2017 MSOMS MSP nicconf Nordic Virtual Summit OperationsManager OpsMgr Powershell QUickPublish rest SCDPM SCOM SCOM2016 SCVMM Serverless SquaredUP SysCtr system center Webasto

Follow Martin Ehrnst

  • Twitter
  • LinkedIn

RSS Feed RSS - Posts

RSS Feed RSS - Comments

Microsoft Azure MVP

Martin Ehrnst Microsoft Azure MVP

NiCE Active 365 Monitor for Azure

NiCE active 365 monitor for Azure
Adatum.no use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. Cookie Policy
Theme by Colorlib Powered by WordPress