Hola Anthony, podriamos utilizar vbs. Este por ejemplo te da los usuarios si estan habilitados o no, el ultimo loging y la cantidad de dias desde el ultimo login hasta hoy. Yo no calculo los que ingresaron en los ultimos 30 dias, eso porque asi lo requiero, pero eso es una simple formula de Excel. Esperemos que este te sirva.
Pegas a partir de aqui en un txt y lo guardas como un .vbs
'aqui pone el dominio de la empresa, por ejemplo "test.local"
strPreDomain = "test"
strPostDomain = "local"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 5
objExcel.Cells(1, 1).Value = "Reporte Usuarios"
objExcel.Cells(1, 2).Value = "AD Costa Rica"
objExcel.Cells(2, 6).Value = "Fecha Reporte:"
objExcel.Cells(2, 7).Value = "=NOW()"
objExcel.Cells(4, 1).Value = "Login Name"
objExcel.Cells(4, 2).Value = "First Name"
objExcel.Cells(4, 3).Value = "Last Name"
objExcel.Cells(4, 4).Value = "Full Name"
objExcel.Cells(4, 5).Value = "Description"
objExcel.Cells(4, 6).Value = "Last Login"
objExcel.Cells(4, 7).Value = "Password Last Changed"
objExcel.Cells(4, 8).Value = "AccountEnable"
objExcel.Cells(4, 9).Value = "Días Sin Sesión"
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "Select ADsPath From 'LDAP://dc=" & strPreDomain & ",dc=" & strPostDomain & "' Where objectCategory='User' And userPrincipalName = '*'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strPath = objRecordSet.Fields("ADsPath").Value
Set objUser = GetObject(strPath)
objExcel.Cells(intRow, 1).Value = objUser.sAMAccountName
objExcel.Cells(intRow, 2).Value = objUser.FirstName
objExcel.Cells(intRow, 3).Value = objUser.LastName
objExcel.Cells(intRow, 4).Value = objUser.FullName
objExcel.Cells(intRow, 5).Value = objUser.Description
objExcel.Cells(intRow, 6).Value = objUser.LastLogin
objExcel.Cells(intRow, 7).Value = objUser.PasswordLastChanged
IsAccountDisabled = objUser.AccountDisabled
If IsAccountDisabled = "False" Then
objExcel.Cells(intRow, 8).Value = "Account enabled"
Else
objExcel.Cells(intRow, 8).Value = "Account disabled"
End If
'cellFormula = "$G$2-F"&intRow
objExcel.Cells(intRow, 9).Value = "=IF(($G$2-F"&intRow&")>30,($G$2-F"&intRow&"),)"
objRecordSet.MoveNext
intRow = intRow + 1
Loop
objExcel.Range("A4:I4").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("A5")
objRange.Sort objRange,1,,,,,,1
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Range("F2:G2").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
MsgBox "Done"