<div class="im" style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div class="gmail_quote">On 10 August 2012 12:34, Malte Hohmann <span dir="ltr"><<a href="mailto:groups@daooze.de" target="_blank">groups@daooze.de</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi there,<br><br>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.<br>


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!<br><br>My suggestion is to add a new check to wpkg. This could be something like:<br>


<br><check type="host" condition="role" value="domaincontroller" /><br><check type="host" condition="role" value="workstation,server" /><br><br>or similar.<br>

</blockquote><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)"><br></div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">

I've not tested this, but this may work:</div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)"><br></div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">

<check type="execute" path="\\path\to\ComputerRole.vbs" condition="exitcodesmallerthan" value="4" ></div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">

<br></div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)"><div> values of 4 and 5 are Domain Controllers</div></div><div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"> so it will match only workstations and servers</span></div>

<div> </div><div><a href="http://wpkg.org/Packages.xml#Execute">http://wpkg.org/Packages.xml#Execute</a>
</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>I have found some VB code which, with slight modifications, could be used:<br><br>Function DomainRole(sNode)<br>    Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sNode & "\root\cimv2")<br>


    Set colComputer = oWMI.ExecQuery("Select DomainRole from Win32_ComputerSystem")<br>    For Each oComputer in colComputer<br>    iDR = oComputer.DomainRole<br>    Next<br><br>    Select Case iDR<br>        Case 0<br>


            DomainRole = "Standalone Workstation"<br>        Case 1<br>            DomainRole = "Member Workstation"<br>        Case 2<br>            DomainRole = "Standalone Server"<br>        Case 3<br>


            DomainRole = "Member Server"<br>        Case 4<br>            DomainRole = "Backup Domain Controller"<br>        Case 5<br>            DomainRole = "Primary Domain Controller"<br>


        Case Else<br>            DomainRole = "Unknown"<br>    End Select<br><br>End Function<br></blockquote><div><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">ComputerRole.VBS (checks for returnvalue)</div>

<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">strComputer = "."</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

Set objWMIService = GetObject("winmgmts:" _</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">    & "{impersonationLevel=impersonate}!\\" _</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

    & strComputer & "\root\cimv2")</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Set colComputers = objWMIService.ExecQuery _</div><div class="im" style="font-family:arial,sans-serif;font-size:13px;color:rgb(80,0,80)">

    ("Select DomainRole from Win32_ComputerSystem")</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">For Each objComputer in colComputers</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

<span style="white-space:pre-wrap">     </span></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">    Select Case objComputer.DomainRole </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

<span style="white-space:pre-wrap">     </span>Case 0 </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">            strComputerRole = "Standalone Workstation"</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

        Case 1        </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">            strComputerRole = "Member Workstation"</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

        Case 2</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">            strComputerRole = "Standalone Server"</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

        Case 3</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">            strComputerRole = "Member Server"</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

        Case 4</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">            strComputerRole = "Backup Domain Controller"</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

        Case 5</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">            strComputerRole = "Primary Domain Controller"</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">

    End Select</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">    Wscript.Echo strComputerRole</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">     </span>returnvalue = objComputer.DomainRole</div>

<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Next</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">WScript.Quit(returnValue) </span></div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>Regards,<br>Malte<br>
<br>-------------------------------------------------------------------------<br>
wpkg-users mailing list archives >> <a href="http://lists.wpkg.org/pipermail/wpkg-users/" target="_blank">http://lists.wpkg.org/pipermail/wpkg-users/</a><br>
_______________________________________________<br>
wpkg-users mailing list<br>
<a href="mailto:wpkg-users@lists.wpkg.org">wpkg-users@lists.wpkg.org</a><br>
<a href="http://lists.wpkg.org/mailman/listinfo/wpkg-users" target="_blank">http://lists.wpkg.org/mailman/listinfo/wpkg-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Carl van Eijk<br>