Active Directory Computer Accounts

I found this utility oldcmp on the internet that makes it easier to find old computer accounts in active directory.

You have to be careful with this utility so you do not accidentally delete computer accounts that are being used.

Another note, in my testing Macintosh computers do not update their computer password as frequently as PCs do.

Microsoft Product Key Recovery.

We lost our product key for ISA 2006, so after some internet browsing i found the script below. Just point it to the DigitalProductID value in your registry for the Microsoft product that you need the installation key for.

Original Link

Rem lookup digital product id from registry
Set WshShell = WScript.CreateObject("WScript.Shell")
HexBuf = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")
For l = lBound(HexBuf) to uBound(HexBuf)
tmp=tmp & " "& Hex (HexBuf(l))
next

WshShell.Popup  "Found Digital Product Id in registry:-" &  _
"                                                                                                                    " &  _
"                                                                                                                    " &  _
"                                                                                                                    " & tmp
StartOffset = 52
EndOffset =67
Dim Digits (24)

Digits (0) = "B" : Digits (1) = "C": Digits (2) = "D": Digits (3) = "F":
Digits (4) = "G": Digits (5) = "H": Digits (6) = "J": Digits (7) = "K":
Digits (8) = "M": Digits (9) = "P": Digits (10) = "Q": Digits (11) = "R":
Digits (12) = "T": Digits (13) = "V": Digits (14) = "W": Digits (15) = "X":
Digits (16) = "Y": Digits (17) = "2": Digits (18) = "3": Digits (19) = "4":
Digits (20) = "6" : Digits (21) = "7" : Digits (22) = "8": Digits (23) = "9"

dLen = 29
sLen = 15
Dim HexDigitalPID (15)
Dim Des (30)
For i = StartOffset to EndOffset
HexDigitalPID (i-StartOffset) = HexBuf(i)
tmp2=tmp2 & " "& Hex (HexDigitalPID(i-StartOffset))
next
WshShell.Popup  "Found Digital Product Id in registry:-" &  _
"                                                                                                                    " &  _
"                                                                                                                    " &  _
"                                                                                                                    " & tmp & _
"                                                                                                                  " & _
"                                                                                                                  " & _
"                                                                                                                  " & _
"                                        " & _
"Located the sequence in the digital product ID. Can you see it in the one above (Tip:- 2nd line, 8 in from the left) :- " & _
"                                                                                                                  " &  _
"                                                                                                                  " & tmp2
KEYSTRING =""
for i=dLen-1 to 0 step -1
if ((i + 1) mod 6) = 0 then
Des (i) = "-"
KEYSTRING =KEYSTRING & "-"
else
HN = 0
   For N = (sLen -1) to 0 step -1
     Value = ( (HN *2^8 ) Or HexDigitalPID (N))
      HexDigitalPID (N) = Value \ 24
      HN    = (Value mod 24)

   next

Des(i) = Digits(HN)
KEYSTRING =KEYSTRING & Digits(HN)
end if
next
KEYSTRING2 = StrReverse (KEYSTRING)
WScript.Echo "Having finished messing about performing mathmatical stuff" & _
" on your Product ID i have come to the conclusion your XP Key is:- " & _
"                                         " & KEYSTRING2

Expand a Logical Drive using existing free space on a DS3200.

Here is the command for smcli to expand an existing Logical Drive. I had to mix documentation from Dell, IBM, and SANtricity to get a working command line. The ; at the end of the line is required. i just ran smcli localhost and pasted the below command.

This is not the same as add capacity in the GUI.

Here is the command information to expand the drive in windows.

set logicaldrive["name or label of logical drive"] addCapacity=SizeinBytes;

Hidden Logon Script

This little vbscript wrapper will let you start a logon script hidden. Our logon scripts are batch and perl files and they all start with the black box. If you launch the script like hidelaunch.vbs logon.bat it will start the logon script hidden.

Set wshShell = CreateObject("WScript.Shell")
set args = wscript.arguments

command = ""

for each strArg in args
 command = strArg + " "
next

wshshell.run command, 0, false

iMail aliases.txt to csv converter.

This will convert iMails aliases.txt file to a csv to import into outlook or similar.

'Convert imail alias.txt to something that is not useless.

Const ForReading = 1, ForWriting = 2, ForAppending = 8 

Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("aliases.txt", ForReading) 

Set filetxtOUT = filesys.OpenTextFile("aliasesOUT.csv", ForWriting, TRUE) 
Set filetxtBAD = filesys.OpenTextFile("aliasesBAD.txt", ForWriting, TRUE) 

'get name
Set nameRegex = New RegExp
nameRegex.IgnoreCase = True
nameRegex.Pattern = """(.*?)"""

'get email
Set emailRegex = New RegExp
emailRegex.IgnoreCase = True
emailRegex.Pattern = "<(.*?)>"

filetxtOUT.WriteLine "Name, Email Address"
Do until filetxt.AtEndofStream
 txtline = filetxt.Readline
 
 'get name if 0 name is bad
 Set namevar = nameRegex.Execute(txtline)
 if namevar.Count = 0 then
  name = ""
 else
  name = namevar(0).Value
 end if

 'get email address if 0 email is bad
 Set emailvar = emailRegex.Execute(txtline)
 if emailvar.Count = 0 then
  email = ""
 else
  email = emailvar(0).Value
 end if

 'record bad lines to bad file
 if namevar.count = 0 AND emailvar.count = 0 then
  filetxtBAD.writeline txtline
 else
  if len(name) > 2 then
   filetxtOUT.writeline name & "," & email
  else
   filetxtOUT.writeline """" & name & """," & email
  end if
 end if
 
  
  
loop

filetxt.Close
msgbox "DONE"

Logon Tracker

This is the client part of a script that collects the username and computer name and sends it to a database for tracking purposes, when I find the server side of the script I will post that also.

#!/usr/bin/perl
#Grabs Certain local data and send it to an ICC database.

$user = $ENV{'USER'};
use Sys::Hostname;

use LWP::UserAgent; 
my $ua = new LWP::UserAgent;

my $response
= $ua->post('http://web.url.com/getlinfo.asp',
{ user => $user,
machine => hostname,
});

my $content = $response->content; 

Using perl to Parse AD’s UserAccountControl field

To parse the UserAccountControl field in Active Directory you have to use a bit-wise and of “&” and not “&&” to check the value. Below are some examples Here is a MSDN page that has more information.

This MS site also has more values listed.

#Check if the account is Disabled
$strStatus & 2

#Check if the account is Locked
$strStatus & 16