All Forums >> [Scripting] >> WSH & Client Side VBScript >> Detecting Computer Name with a twist; need some ideas Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
I just got an unusual request from my supevisor. When anyone in our OU logs onto certain clients then normal post login script processing must halt. He said the networking guy said the computers could be put in a security group for detection. That's my first question, I thought only user accounts could be put into security groups; is this true? It is true then how would you detect that group?
DS, Thanks for the tip. I did it a bit different but I have a question regarding simplicity. Look at the code below:
OBTW, anyone can chime in with an improvement -- I need all the improvement I can get. <ggg>
What I would like to know is, is there a way to simply the adspath, mine is long, long, long ... sheesh ...
How can the above be simplified? Also, who's idea was it that you had to specify the OUs from inside out and the DC from outside in? That makes no sense at all.
Anyway, the above subroutine works, I would just like to improve it if possible. The subroutine is a re-hash of the bubble sort script you can find up on the Scripting Guys site. A lot of useful stuff there.
Well, have you ever looked at the ADSystemInfo object?
[code] Sub ExamRoomLookUp strExamExit = "N" strComputer = objNetwork.ComputerName
Set oAD = CreateObject("ADSystemInfo") strComputerDN = oAD.ComputerName
Dim arrNames() intSize = 0 Set objGroup = GetObject("LDAP://" & strComputerDN) For Each strUser in objGroup.Member Set objUser = GetObject("LDAP://" & strUser) ReDim Preserve arrNames(intSize) arrNames(intSize) = objUser.CN intSize = intSize + 1 Next For i = (UBound(arrNames) - 1) to 0 Step -1 For j= 0 to i If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then strHolder = arrNames(j+1) arrNames(j+1) = arrNames(j) arrNames(j) = strHolder End If Next Next For Each strName in arrNames Wscript.Echo strName If strComputer = strName Then 'Wscript.Echo "Computer " & strComputer & " is located in a Exam Room." strExamExit = "Y" Else 'Wscript.Echo "Computer " & strComputer & " is NOT an Exam Room computer." End If Next End Sub
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers)
"It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury