Active directory can be a bit of a beast if not managed and maintained correctly. Using this code in a .vbs file you can output all currently disabled accounts.

You may want to expand this by using the file system object to output to a file?

Const ADS_UF_ACCOUNTDISABLE = 2
 
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    ";(objectCategory=User)" & _
        ";userAccountControl,distinguishedName;subtree"  
Set objRecordSet = objCommand.Execute
 
intCounter = 0
Do Until objRecordset.EOF


Use this simple VB.NET code to convert bytes to MB’s, GB’s etc. Handy for returning sizes of files/folders

Function ConvertSize(Size)
Do While InStr(Size,",") 'Remove commas from size
CommaLocate = InStr(Size,",")
     Size = Mid(Size,1,CommaLocate - 1) & _
       Mid(Size,CommaLocate + 1,Len(Size) - CommaLocate)
       Loop</p> <p>Suffix = " Bytes"

   If Size >= 1024 Then suffix = " KB"
   If Size >= 1048576 Then suffix = " MB"
   If Size >= 1073741824 Then suffix = " GB"
   If Size >= 1099511627776 Then suffix = " TB"

        Select Case Suffix
            Case " KB" Size = Round(Size / 1024, 1)
            Case " MB" Size = Round(Size / 1048576, 1)
            Case " GB" Size = Round(Size / 1073741824, 1)
            Case " TB" Size = Round(Size / 1099511627776, 1)
        End Select

        ConvertSize = Size & Suffix

End Function


Use this simple VB.NET code to return the name of the month from an integer.
Example: 1 = January ….. 12 = December



Use this really simple VBScript to get the currently logged on user name.

Set wshNetwork = CreateObject("WScript.Network")
strUser = wshNetwork.Username
WScript.Echo "Current User: " & strUser


Use this fairly simple VBScript to list general opearating system properties.

' List Operating System Properties
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}" & strComputer & "rootcimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
Wscript.Echo "Boot Device: " & objOperatingSystem.BootDevice
Wscript.Echo "Build Number: " & objOperatingSystem.BuildNumber
Wscript.Echo "Build Type: " & objOperatingSystem.BuildType
Wscript.Echo "Caption: " & objOperatingSystem.Caption
Wscript.Echo "Code Set: " & objOperatingSystem.CodeSet
Wscript.Echo "Country Code: " & objOperatingSystem.CountryCode
Wscript.Echo "Debug: " & objOperatingSystem.Debug
Wscript.Echo "Encryption Level: " & objOperatingSystem.EncryptionLevel
dtmConvertedDate.Value = objOperatingSystem.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
Wscript.Echo "Install Date: " & dtmInstallDate
Wscript.Echo "Licensed Users: " & _
objOperatingSystem.NumberOfLicensedUsers
Wscript.Echo "Organization: " & objOperatingSystem.Organization
Wscript.Echo "OS Language: " & objOperatingSystem.OSLanguage
Wscript.Echo "OS Product Suite: " & objOperatingSystem.OSProductSuite
Wscript.Echo "OS Type: " & objOperatingSystem.OSType
Wscript.Echo "Primary: " & objOperatingSystem.Primary
Wscript.Echo "Registered User: " & objOperatingSystem.RegisteredUser
Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber
Wscript.Echo "Version: " & objOperatingSystem.Version
Next



Page 2 of 3123