[wpkg-users] Add check for 'computer-role'
Carl van Eijk
carl.vaneijk+wpkg at gmail.com
Fri Aug 10 15:09:26 CEST 2012
On 10 August 2012 12:34, Malte Hohmann <groups at daooze.de> wrote:
> 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've not tested this, but this may work:
<check type="execute" path="\\path\to\ComputerRole.vbs"
condition="exitcodesmallerthan" value="4" >
values of 4 and 5 are Domain Controllers
so it will match only workstations and servers
http://wpkg.org/Packages.xml#Execute
> 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
>
ComputerRole.VBS (checks for returnvalue)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select DomainRole from Win32_ComputerSystem")
For Each objComputer in colComputers
Select Case objComputer.DomainRole
Case 0
strComputerRole = "Standalone Workstation"
Case 1
strComputerRole = "Member Workstation"
Case 2
strComputerRole = "Standalone Server"
Case 3
strComputerRole = "Member Server"
Case 4
strComputerRole = "Backup Domain Controller"
Case 5
strComputerRole = "Primary Domain Controller"
End Select
Wscript.Echo strComputerRole
returnvalue = objComputer.DomainRole
Next
WScript.Quit(returnValue)
>
> Regards,
> Malte
>
> -------------------------------------------------------------------------
> wpkg-users mailing list archives >>
> http://lists.wpkg.org/pipermail/wpkg-users/
> _______________________________________________
> wpkg-users mailing list
> wpkg-users at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/wpkg-users
>
>
--
Carl van Eijk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/wpkg-users/attachments/20120810/8504bb97/attachment-0002.html>
More information about the wpkg-users
mailing list