Where is my SCOM installed?

This will be a short tip on how to get something really useful, especially if you have many OM environment to work with regardless its version. Recently there was a question internally how to run a script or a command and pass SCOM installation directory within XML tag. This was normal in OM07, but install directory has changed in OM12 from

%ProgramFiles%\System Center Operations Manager 2007

to

%ProgramFiles%\System Center 2012\Operations Manager\Server

If you migrated to OM12, you have a mixture of OM07 and OM12, you don’t want to change your management packs

 

Method #1:

You can create a junction to this new folder on every OM12 server:

mklink /J “C:\Program Files\System Center Operations Manager 2007” “C:\Program Files\System Center 2012\Operations Manager\Server”

So now everytime something points to first folder it will be really pointing to new one, but will never know about it.

image

 

Method #2:

If you can’t make any modifications to folder structure or it is easier to create a global solution, you can populate environmental variable with installation directory from registry, but this will enforce you to change your MPs to reflect your new environmental variable too. If you are writing a new MP – this is probably better solution.

 

$scomdir = (New-Object –ComObject Wscript.Shell).RegRead("HKLM\SOFTWARE\Microsoft Operations Manager\3.0\Setup\InstallDirectory")

[Environment]::SetEnvironmentVariable("SCOMDir", $scomdir, "Machine")

And then you can use it as:

<OpsMgrInstallPath>"%SCOMDir%"</OpsMgrInstallPath>

image