Jump to content

Prodigus

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Prodigus

  1. Thank You! It's a function of a script I'm writing to gather all of my servers names from AD (about 300) then create Global Groups for each of them to contain the local admins. This is just to add each of those global groups to the local admins group on each server.... Then populate the global group with the domain users who are now members of the local groups. I want to be able to manage local admins from a higher level is all... Thanks again!!
  2. $sCmd2run = 'psexec \\'& $var1 & 'net localgroup administrators /add' '"sleh\'&$var2"' $sErrorStatus = RunWait($sCmd2Run, @ScriptDir, @SW_HIDE) I just can't seem to get all my ' and " in the right place on this one.... GRRRRRR
  3. I was just trying to use the Ctrl+B to use an abbreviation and it didn't work.. I investigated.. Options ---> Open Abbreviations File It's empty except for the standard #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# Created by UpdateDefs (don't change anything between the dashed lines) #------------------------------------------------------------ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# I uninstalled everything, deleted all directories and installed the latest and greatest.. Still empty. Anyone else had this issue or is the abbreviations file only for abbreviations that you create for yourself? Thanks!!
  4. Woot!! That did it! Thanks!! Could have swore it was supposed to increment on its own but I probably have something else fubared in there.. Thanks for the help!
  5. I can't seem to figure out why all of a sudden the $var1 isn't going to the next line of the file when it loops. $var1 is in red in the code here. It was working earlier but some other stuff wasn't. Only thing I really changed was how I opened that file and stated that it was $var1. Was necessary since all of a sudden it was telling me that I was using an invalid file handle at that same spot (come to think of it)... Anyway, been tinkering with this stuff for too long. It seems to be VERY addictive. This could be a problem.. Ok, seems to not want to let me add color to the code so it's the line just inside the While 1 that says $var1 = FileReadLine($mfile) everytime I loop around it "should" go to the next line. I don't see where I'm closing it anywhere.. Perhaps a beer would help? #include <_Trentlib.au3> #include <Process.au3> $ofile = ("Outputfile.txt") GatherComp() CreateVars() Func GatherComp() ;exports all computer objects from within AD that have Professional in their OS Name to a file named MYMACHINES.txt ;MsgBox(0, "Run GatherComp Func?:", "You have entered the GatherComp function") $sCmd2Run = "logparser ""SELECT cn INTO MYMACHINES.txt FROM ""LDAP://sleh.com/DC=MY,DC=COM"" WHERE operatingSystem LIKE '%Professional%'"" -i:ADS -objClass:computer -o:TSV -headers:off -filemode:1" $sErrorStatus = RunWait($sCmd2Run, @ScriptDir, @SW_HIDE) ;MsgBox(0, "Error Status", "Error Status = '" & $sErrorStatus & "'") EndFunc Func CreateVars();gathers the image type and IPAddress of each computer that was gathered by GatherComp Function ;----------------------------------------------------------------------------------------------------------------------- ;Opens MYMACHINES.txt for reading. If the file does not exist then it will return out of the function $mfile = ( "MYMACHINES.txt" ) FileOpen($mfile, 0) If $mfile = -1 Then Return ;----------------------------------------------------------------------------------------------------------------------- While 1 MsgBox(0, "Start Loop", "At beginning") $var1 = FileReadLine($mfile) MsgBox(0, "Var1=", $var1) If @error = -1 Then FileClose ($mfile) ExitLoop EndIf $pingit = "alive /Repeat=3 /Timeout=1 " & $var1 $rc = _RunDos($pingit) If $rc = 0 Then $sCmd2Run = 'alive ' & $var1 & ' > getip.txt ' _RunDOS($sCmd2Run) ;_Runtest($sCmd2Run) $ip = FileOpen ("getip.txt", 0) $ip = FileReadLine ("getip.txt", 3) FileClose ( $ip ) $String = StringSplit ( $ip, "(" & ")") $var2 = $String[2] FileDelete ("getip.txt") MsgBox(0, "IP Address", $var2) FileOpen($ofile, 1) FileWriteLine ($ofile,$var1 & "," & $var2) FileClose($ofile) Else $var2 = "" FileOpen($ofile, 1) FileWriteLine ($ofile,$var1 & "," & $var2) FileClose($ofile) MsgBox(0, "Looping Now?", "at end") EndIf WEnd EndFunc
  6. Thanks!!!!! Solves a big problem I was having......
  7. I just want to grab the IP address out of this string 6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194) is alive. I would thing there would be a function where I could just grab whatever is between "(" and ")" Is there? The count would be different from left or right depending on the date and the IP address so I didn't think I could do it with a StringTrimLeft or right...
  8. yup, that works great!! Thanks!! Of course now that that works I found a new problem where some machines somehow have 2 DhcpIPAddresses but that's another story... Perhaps I can get the IP address from DNS or perhaps just by pinging it.. We'll see.. Thanks !!!
  9. Yes, when you run this command with logparser it will return the IP address of the machine (as long as a) the machine is on and the IP was issued through DHCP. "logparser ""SELECT Value FROM ""\\23T7111\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -headers:off" That machine name is actually replaced by a variable in the actual script
  10. I know this isn't the best code in the world but I'm just trying to learn. I'm wondering if there's some happy medium between a RunWait and actually putting a pause in the Red area below. You see, if a computer is offline then the logparser has to time out before I can go on to the next computer on my list. I would rather not wait any longer that 3 seconds before going on to the next one as if the computer is online it normally only takes about 0.3 seconds to get the result. I would rather just leave that one blank and go on. Is pause and RunWait my only 2 options? Func CreateVar1() ;gathers the image type and IPAddress of each computer that was gathered by GatherComp Function $mfile = FileOpen("MYMACHINES.txt", 0) If $mfile = -1 Then Return While 1 $var1 = FileReadLine($mfile) If @error = -1 Then FileClose ($mfile) ExitLoop EndIf $sCmd2Run2 = "logparser ""SELECT Value INTO ip.txt FROM ""\\"&$var1&"\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -o:TSV -headers:off" $sErrorStatus = RunWait($sCmd2Run2, @ScriptDir, @SW_HIDE) $ipfile= Fileopen("ip.txt", 0) $var2= FileReadLine($ipfile) If @error = -1 Then FileClose ($ipfile) ExitLoop EndIf FileClose($ipfile) FileOpen($ofile, 1) FileWriteLine ($ofile,$var1 & "," & $var2) FileClose($ofile) FileDelete ( "ip.txt" ) WEnd EndFunc Thanks, Prod
  11. lol The end result of the script I'm working on is not very exciting actually it will merely move computers around within Active Directory to different OU's based on their IP address and the "imagetype" registry key that our techs added to the administrative and clinical images of all machines in the enterprise. The image type will tell me which top level OU it belongs to and then the IP address will tell me the geographical location of the machine. From that information I can keep machines in their proper OU's and thus they get their proper GPO's applied for that location and type. So even if someone moves a machine, I'll know.... But right now I'd just like to figure out how to take the results of a query and have it automatically recognized as a variable versus having to do that many reads and writes from another txt file..... Thanks!!
  12. This is probably an easy thing for you pros but I'm just getting started at this (and can't stop)... I'm trying to grab some information using logparser (a computers IP address) and I want the result of the Query (the IP address) to be $var2 (my variable name that I'm going to use. $sCmd2Run2 = "logparser ""SELECT Value FROM ""\\23T7111\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -headers:off" $sErrorStatus = RunWait($sCmd2Run2, @ScriptDir, @SW_HIDE) if I run this it will return a IP address, I merely want that IP address to be automatically recognized as $var2 I don't want to have to place it in a txt file first and then read it out of there since I will be doing about 4000 of these and I would think all that opening and closing of the file would take away from my performance. Any ideas? Thanks!!
×
×
  • Create New...