The ADAuditTasks module provides a comprehensive set of tools for auditing and reporting on Active Directory resources, including users, computers, and network devices. The module generates logs, CSV output, and report objects, which can be sent via email using the Send-AuditEmail function.
See the ADAuditTasks help documentation or the Wiki for more information on this module and how to use it.
The following Public Functions are available to the user executing the tasks:
Convert-NmapXMLToCSVGet-ADActiveUserAuditGet-ADHostAuditGet-ADUserLogonAuditGet-ADUserPrivilegeAuditGet-ADUserWildCardAuditGet-NetworkAuditGet-WebCertAuditGet-HostTagGet-QuickPingJoin-CSVFileMerge-ADAuditZipMerge-NmapToADHostAuditSend-AuditEmailSubmit-FTPUpload
The following Private Functions support the functions in this module:
Build-ADAuditTasksComputerBuild-ADAuditTasksUserInitialize-DirectoryPathBuild-MacIdOUIListBuild-NetScanObjectBuild-ReportArchiveGet-AdExtendedRightGet-ADGroupMemberofInitialize-ModuleEnvInstall-ADModuleRead-FileContentTest-IsAdminWrite-AuditLog
The following example demonstrates how to create a zip file of different host types:
$workstations = Get-ADHostAudit -HostType WindowsWorkstations -Report
$servers = Get-ADHostAudit -HostType WindowsServers -Report
$nonWindows = Get-ADHostAudit -HostType "Non-Windows" -Report
Merge-ADAuditZip -FilePaths $workstations, $servers, $nonWindowsThis example shows how to send an email with an attachment file generated by the Get-ADActiveUserAudit function using the Send-AuditEmail function.
Send-AuditEmail -SMTPServer "smtp.office365.com" -Port 587 -UserName "[email protected]" `
-From "[email protected]" -To "[email protected]" -Pass (Read-Host -AsSecureString) -AttachmentFiles "$(Get-ADActiveUserAudit -Report)" -SSLThis example shows how to send an email with an attachment file generated by the Get-ADActiveUserAudit function, along with a body and a custom date stamp.
$SMTPServer = "smtp.office365.com"
$Port = 587
$UserName = "[email protected]"
$From = "[email protected]"
$To = "[email protected]"
$password = Read-Host -AsSecureString
$date = (Get-Date).tostring("yyyy-MM-dd_hh.mm.ss")
$Body = "Report run on $date for $env:USERDNSDOMAIN"
Send-AuditEmail -smtpServer $SMTPServer -port $Port -username $UserName `
-body $Body -from $From -to $To -pass $password -attachmentfiles "$(Get-ADActiveUserAudit -Report)" -sslThis example demonstrates how to create a ZIP file that could be split into multiple parts.
$workstations = Get-ADHostAudit -HostType WindowsWorkstations -Report -Verbose
$servers = Get-ADHostAudit -HostType WindowsServers -Report -Verbose
$nonWindows = Get-ADHostAudit -HostType "Non-Windows" -Report -Verbose
$activeUsers = Get-ADActiveUserAudit -Report -Verbose
$privilegedUsers = Get-ADUserPrivilegeAudit -Report -Verbose
$wildcardUsers = Get-ADUserWildCardAudit -WildCardIdentifier "svc" -Report -Verbose
Merge-ADAuditZip -FilePaths $workstations, $servers, $nonWindows, $activeUsers, $privilegedUsers, $wildcardUsers -MaxFileSize 100MB -OutputFolder "C:\Temp" -OpenDirectoryThis example demonstrates how to create a ZIP file that could be split into multiple parts and emailed.
# Function Variables
$workstations = Get-ADHostAudit -HostType WindowsWorkstations -Report -Verbose
$servers = Get-ADHostAudit -HostType WindowsServers -Report -Verbose
$nonWindows = Get-ADHostAudit -HostType "Non-Windows" -Report -Verbose
$activeUsers = Get-ADActiveUserAudit -Report -Verbose
$privilegedUsers = Get-ADUserPrivilegeAudit -Report -Verbose
$wildcardUsers = Get-ADUserWildCardAudit -WildCardIdentifier "svc" -Report -Verbose
# Email Variables
$SMTPServer = "smtp.office365.com"
$Port = 587
$UserName = "[email protected]"
$From = "[email protected]"
$To = "[email protected]"
$password = Read-Host -AsSecureString
$date = (Get-Date).tostring("yyyy-MM-dd_hh.mm.ss")
$Body = "Report run on $date for $env:USERDNSDOMAIN"
$attachments = Merge-ADAuditZip -FilePaths $workstations, $servers, $nonWindows, $activeUsers, $privilegedUsers, $wildcardUsers
Send-AuditEmail -smtpServer $SMTPServer -port $Port -username $UserName `
-body $Body -from $From -to $To -pass $password -attachmentfiles $attachments -ssl