Operations Manager – Dynamic Group Using Regular Expression

I have a bunch of machines that are all named using the same syntax that I would like to create a dynamic group for.  The computer names all look like AA-DEV-AA where the ending AA is always the individual developers initials.  In my case my computer name would be AA-DEV-JB.  I created the dynamic group using the regular expression below.

The ?i: ensures that the expression is not case sensitive.  The $ at the end is because there are some machines that are named things like AA-DEV-SQL which I don’t want to include in the group.

Use Start-Sleep to Delay PowerShell Script Execution in Operations Manager Recovery Task

I had an issue where I needed a monitor in Operations Manager to start a service when it crashed.  Which is easy enough to do (you can find all kinds of examples on it), except that in my case the service wasn’t just stopping immediately.  It is a custom homegrown application that detected a dropped connection, wrote an event to the event log (which Operations Manager was watching), and then killed the service.  The problem is that it would write the event, and then attempt to stop the service, which took several seconds to stop.  In that interval Operations Manager would pick up the event, try to start the service, determine that it wasn’t stopped, and fail.  So, I needed to figure out a way to “delay” the recovery task.  I couldn’t find a way to do this natively in the recovery task, so I did it in PowerShell.  The PowerShell “script” itself was a simple two lines.

This forced the script to wait 30 seconds to run, and then started the service.  Here is what the recovery task in SCOM looks like.

Capture

Update Custom Property Field in VMM with the Last Update Date

We recently added four custom fields to Virtual Machine Manager (VMM) to help us keep track of application owners, server owners, when in our patch schedule servers were being updated, and the last time a server was updated.  In order to keep the field for last update current, I wrote a script to get the date the server was last updated, compare it to the value currently in the field, and if the new date was later than the value in the custom property, to change it.  Now there are certainly some issues with this script that need improving.  The main issue being that if there are multiple updates with different update days, it doesn’t pick out each unique one, or the latest one, and so updates the property in VMM multiple times.  I have this script running as a scheduled task on the VMM server once a week and it is working great.

Examples: Using Get-VM and Where-Object

I had two cases last week where I needed to get a certain subset of VM’s and specified properties from Virtual Machine Manager.  The first scenario involved SQL servers, which due to our server naming convention was fairly easy.

The next scenario involved using a list of VM’s that was provided in a text file.  I initially struggled with this but eventually got it worked out using the two lines below.  You could also do it in one line but that gets kind of messy.

Virtual Machine Manager (VMM) – Event ID 5004

Last night my VMM server crashed, with Ops Manager generating about 20 errors in less than a minute.  The System Center Virtual Machine Manager service had stopped, and could not be started again.  I looked in the event log Microsoft -> Virtual Machine Manager -> Server -> Operational and saw the following entries for every time the service had tried to start:

Capture

So I opened up the log file to take a look and see what it said.  At the very top were the following lines, with the important ones in bold.

—————————————————-
————— Bucketing Parameters —————
—————————————————-
EventType=VMM20
P1(appName)=vmmservice.exe
P2(appVersion)=3.2.7510.0
P3(assemblyName)=unknown
P4(assemblyVer)=0.0.0.0
P5(methodName)=unknown
P6(exceptionType)=Microsoft.VirtualManager.DB.NonFatalDbException
P7(callstackHash)=5844

SCVMM Version=3.2.7510.0
SCVMM flavor=C-RTL-AMD64
Default Assembly Version=3.2.7510.0
Executable Name=vmmservice.exe
Executable Version=3.2.7510.0
Base Exception Target Site=unknown
Base Exception Assembly name=unknown
Base Exception Method Name=unknown
Exception Message=Database operation failed.
Ensure that the SQL Server is running and configured correctly, and try the operation again.
EIP=0x000007fcf372811c
Build bit-size=64

Well, that’s not good, although if something was really wrong with the SQL server I would have expected the other Systems Center components to have issues since their databases also share that same server.  So I go over to that server and try to connect to the VMM instance and get the following error.

vmmsql

Just to double check, I verify I can login to the other instances on the server with no problems.  The SQL Server (VMM) service is running, but as a troubleshooting step I restart it anyways.  After the service restart I can connect to the instance and browse the database.  Over on the VMM server I am able to start the System Center Virtual Machine Manager service with no problems.  Everything is now good to go.

Of course, now I just need to figure out why this happened.

Excel – Contents of Cell Based On Another Cell

I had the need this morning in Excel to have the contents of one cell be based on the text of what was in another cell.  For example, if the contents of the first cell was 1, the contents of the next cell needed to be 3rd Saturday – DEV.  A little Google-FU later and I was able to find out how to do this, which saved me a boat load of time this morning.

In the cell that is empty, use a formula like this:

=IF(ISNUMBER(SEARCH(“3″,B2)),”1st Saturday – PROD”)

What this does is if the number is 3, in cell B2, it will place the text 1st Saturday – PROD into your empty cell.  You can also string it together like this for multiple values:

=IF(ISNUMBER(SEARCH(“3″,B2)),”1st Saturday – PROD”,IF(ISNUMBER(SEARCH(“4″,B2)),”2nd Saturday – PROD”,IF(ISNUMBER(SEARCH(“1″,B2)),”3rd Saturday – DEV”,IF(ISNUMBER(SEARCH(“2″,B2)),”4th Saturday – DEV”))))