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

2012-08-10 Thread Carl van Eijk
On 10 August 2012 13:51, Carl van Eijk  wrote:

>
>
> On 10 August 2012 12:34, Malte Hohmann  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:
>>
>> 
>> 
>
>
> I've not tested this, but this may work for you:
>
>  condition="exitcodesmallerthan" value="4" >
>
or perhaps


>
>  values of 4 and 5 are Domain Controllers
>  so it will match only workstations and servers.
>
>
>> 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
>>
>>
> 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)
>
> You can also add users or groups to the local admins using group policies
> (restricted groups)
>
>
>
>
>
>> Regards,
>> Malte
>>
>> -
>> wpkg-users mailing list archives >>
>> http://lists.wpkg.org/pipermail/wpkg-users/
>> ___
>> wpkg-users mailing list
>> wpkg-users@lists.wpkg.org
>> http://lists.wpkg.org/mailman/listinfo/wpkg-users
>>
>>
>
>
> --
> Carl van Eijk
>
-
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
___
wpkg-users mailing list
wpkg-users@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users


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

2012-08-10 Thread Carl van Eijk
On 10 August 2012 12:34, Malte Hohmann  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:
>
> 
> 
>
> or similar.
>

I've not tested this, but this may work:



 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@lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/wpkg-users
>
>


-- 
Carl van Eijk
-
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
___
wpkg-users mailing list
wpkg-users@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users


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

2012-08-10 Thread Malte Hohmann
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:




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
-
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
___
wpkg-users mailing list
wpkg-users@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users