Helper/Test-MgmtServer.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<#�
        .SYNOPSIS�
        Helper�function�to check if it is a SCOM management server
#>

Function Test-MgmtServer
{
    Try
    {
        $ServerRegistryKey = 'HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Server Management Groups'

        If((Test-Path $ServerRegistryKey))
        {
            $ServerSubkey = (Get-ChildItem -Path $ServerRegistryKey).GetValue('IsServer')
            If($ServerSubkey -eq '1')
            {
                $true
            }
        }
        Else
        {
            $false
        }
    }
    Catch
    {
        $Error[0].Exception.Message
    }
}