[wpkg-users] Add check for 'computer-role'

Malte Hohmann groups at daooze.de
Fri Aug 10 13:34:40 CEST 2012


Hi there,

I often get into a situation where I need to know, inside a package, which
role the local computer has. For example I have a package which deploys a
backup software. For this software to work it is necesssary to add a
pre-defined user-account to the group of local administrators. This, of
cause, would fail on a domain controller as this machine does not have
'local' groups, so I need to skip these steps on domain controllers.
At the moment this is done by adding hostname checks, but these checks will
fail if there is a computer not named after out naming-convention. And this
is, however, just _one_ example!

My suggestion is to add a new check to wpkg. This could be something like:

<check type="host" condition="role" value="domaincontroller" />
<check type="host" condition="role" value="workstation,server" />

or similar.

I have found some VB code which, with slight modifications, could be used:

Function DomainRole(sNode)
    Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
sNode & "\root\cimv2")
    Set colComputer = oWMI.ExecQuery("Select DomainRole from
Win32_ComputerSystem")
    For Each oComputer in colComputer
    iDR = oComputer.DomainRole
    Next

    Select Case iDR
        Case 0
            DomainRole = "Standalone Workstation"
        Case 1
            DomainRole = "Member Workstation"
        Case 2
            DomainRole = "Standalone Server"
        Case 3
            DomainRole = "Member Server"
        Case 4
            DomainRole = "Backup Domain Controller"
        Case 5
            DomainRole = "Primary Domain Controller"
        Case Else
            DomainRole = "Unknown"
    End Select

End Function

Regards,
Malte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/wpkg-users/attachments/20120810/dd1a1b3c/attachment-0001.html>


More information about the wpkg-users mailing list