Showing posts with label vbscript. Show all posts
Showing posts with label vbscript. Show all posts

Wednesday, October 18, 2023

VBScript to R.I.P. Soon

 

It seems like that after 30 years, the good old favorite scripting language for sysadmins is going to rest in peace.

VBScript aka Visual Basic Script was introduced in 1996 and integrates active scripting into Windows environments, and communicates with host applications through Windows Script.This was one of the favorites scripting languages for system administrators.

Microsoft announced VBScript's deprecation October 9th on it's "Deprecated features for Windows Client" article following the September announcement of WordPad end of life.

So, the plan to retire VBScript starts with it being preinstalled via Features on Demand (FoD), and in the "near future" remove it from the OS and only available has a FoD.

It had a been a long and fantastic life for VBScript. For those that never tested PowerShell, now is time to really dig into it. 

Long live VBScript. :)

Monday, November 30, 2015

Scripting - Getting AD Users Logonscript and Account Status


Here's a nice script for getting domain users information and exporting it to a text file.
This script retrieve the following info:
  • Display Name
  • Username
  • Logonscript
  • Account Status
The account status retrives "code numbers" so here the translation of the codes:
  • 514 | Disabled Account
  • 546 | Disabled, Password Not Required
  • 66050 | Disabled, Password Doesn't Expire
  • 66082 | Disabled, Password Doesn't Expire & Not Required
  • 262658 | Disabled, Smartcard Required
  • 262690 | Disabled, Smartcard Required, Password Not Required
  • 328194 | Disabled, Smartcard Required, Password Doesn't Expire
  • 328226 | Disabled, Smartcard Required, Password Doesn't Expire & Not Required
And now, the script:

'**********************************************************************
' Application: Get Domain Users Information
'
' Overview: Get's the following information from domain users:
'            - Display Name
'            - Username
'            - Logonscript
'            - Account Status
'
' Author: FrontSlash Blog (http://www.front-slash.blogspot.com)
'**********************************************************************
 
'-------------------------------------------------------------------------'
'  Variables Declaration                                                  '    
'-------------------------------------------------------------------------'
Dim oContainer
Dim OutPutFile
Dim FileSystem
Dim MyDate


'-------------------------------------------------------------------------'
'  Variables And Objects Initialization                                   '
'-------------------------------------------------------------------------'
MyDate = Date()
MyDate = Replace(MyDate, "/", "-")

Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("DomainUsers" & MyDate & ".txt", True)
Set oContainer = GetObject("LDAP://dc=your,dc=domain,dc=here")
oContainer.Filter = Array("organizationalUnit")
strList = ""


'-------------------------------------------------------------------------'
'  MAIN                                                                   '
'-------------------------------------------------------------------------'

'Enumerate Container
    EnumerateUsers oContainer


'Clean up
    OutPutFile.Close
    Set FileSystem = Nothing
    Set oContainer = Nothing
    Set MyDate = Nothing
    
    'The line below is for testing purposes only.
    'WScript.Echo "Finished"
     WScript.Quit(0)

'Functions
 'EnumerateUsers

   Sub EnumerateUsers(oCont)
    Dim oUser
    For Each oUser In oCont
     'On Error Resume Next
       Select Case LCase(oUser.Class)    
        Case "user"
         If Not IsEmpty(oUser.distinguishedName) Then
          OutPutFile.WriteLine oUser.displayName & ";" & oUser.sAMAccountName & ";" & oUser.scriptPath & ";" & oUser.userAccountControl
         End If
        
        Case "organizationalunit", "container"
         EnumerateUsers oUser
        End Select
     Next
   End Sub


Enjoy it! ;)