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! ;)

Thursday, November 26, 2015

Remote Server Administration Tools (RSAT) for Windows 10 Version 1511 Available

With the release of Windows 10 Version 1511, Microsoft also made available a new version of Remote Server Administration Tools for Windows 10.

Because the main objective it's the compatibility wit the new Windows 10 version, there's not a lot of changes in this version of RSAT although there's this notes on the release log:
  • DHCP Tools. Dhcpmgmt.msc is not available in this release of RSAT, but equivalent Windows PowerShell cmdlets are available.
  • IP Address Management (IPAM) Tools. IPAM tools are not available in this release of RSAT.
  • Network Policy Server Tools. The NPS console is not supported on a Windows client-based operating system, and will be removed from future releases of RSAT.
  • Routing and Remote Access Tools. Routing and Remote Access Tools that are GUI-based cannot be used for remote configuration in this release of RSAT, but the equivalent Windows PowerShell cmdlets are available.

Here's the link for more information and download:

Wednesday, November 25, 2015

Scripting - Merging multiple txt files in one



Here's a nice, quick and simple tip if you need to merge multiple text files (*.txt) in just one:

  1. First put all your txt files in a folder (for example D:\Temp)
  2. Now open command line and navigate to D:\Temp
  3. Next, type the following command:
    for %f in (*.txt) do type "%f"  >> output.txt
  4. And...it's done!