<br><br><div class="gmail_quote">On 10 August 2012 13:51, Carl van Eijk <span dir="ltr"><<a href="mailto:carl.vaneijk@gmail.com" target="_blank">carl.vaneijk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div class="im">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" /> </blockquote>
<div><br></div></div><div>I've not tested this, but this may work for you:</div><div><br></div><div><check type="execute" path="\\path\to\ComputerRole.vbs" condition="exitcodesmallerthan" value="4" ></div>
</div></blockquote><div>or perhaps</div><div><check type="execute" path="cscript \\path\to\ComputerRole.vbs" condition="exitcodesmallerthan" value="4" > </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote">
<div><br></div><div><div> values of 4 and 5 are Domain Controllers</div><div> so it will match only workstations and servers.</div></div><div><div class="h5"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>or similar.<br>
<br>I have found some VB code which, with slight modifications, could be used:<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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><br></blockquote><div><br></div></div></div><div><div>ComputerRole.VBS (checks for returnvalue)</div><div><br></div>
<div>strComputer = "."</div>
<div>Set objWMIService = GetObject("winmgmts:" _</div><div> & "{impersonationLevel=impersonate}!\\" _</div><div> & strComputer & "\root\cimv2")</div><div>Set colComputers = objWMIService.ExecQuery _</div>
<div class="im">
<div> ("Select DomainRole from Win32_ComputerSystem")</div></div><div>For Each objComputer in colComputers</div><div><span style="white-space:pre-wrap"> </span></div><div> Select Case objComputer.DomainRole </div>
<div><span style="white-space:pre-wrap"> </span>Case 0 </div><div> strComputerRole = "Standalone Workstation"</div><div> Case 1 </div><div> strComputerRole = "Member Workstation"</div>
<div> Case 2</div><div> strComputerRole = "Standalone Server"</div><div> Case 3</div><div> strComputerRole = "Member Server"</div><div> Case 4</div><div> strComputerRole = "Backup Domain Controller"</div>
<div> Case 5</div><div> strComputerRole = "Primary Domain Controller"</div><div> End Select</div><div> Wscript.Echo strComputerRole</div><div><span style="white-space:pre-wrap"> </span>returnvalue = objComputer.DomainRole</div>
<div>Next</div><div><br></div><div>WScript.Quit(returnValue) </div></div><div><br></div><div>You can also add users or groups to the local admins using group policies (restricted groups)</div><div><br></div><div><br></div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" target="_blank">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><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Carl van Eijk<br>
</font></span></blockquote></div><br>