Skip to content

This repository contains PowerShell scripts to export Active Directory (AD) user and computer information.

License

Notifications You must be signed in to change notification settings

CyberBunny74/ADExportScripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Active Directory Export Scripts

This repository contains PowerShell scripts to export Active Directory (AD) user and computer information. These scripts can handle different use cases, including exporting data from multiple domain controllers (DCs), exporting data from specific organizational units (OUs), and generating combined reports.


Scripts Overview

1. ADUserExport.ps1

Exports user account details from multiple domain controllers into a single CSV file.

  • Features:

    • Gathers user details such as SID, DisplayName, LastLogonTimestamp, and other account properties.
    • Combines results from multiple domain controllers into a single report.
    • Removes temporary files after processing.
  • Usage:

    1. Update the domain controller variables $DC1 and $DC2 in the script.
    2. Specify the export file paths.
    3. Run the script to generate the report.

2. ADComputerExport.ps1

Exports computer account details from multiple domain controllers into a single CSV file.

  • Features:

    • Gathers computer details such as Name, DNSHostName, IPv4Address, and LastLogonTimestamp.
    • Combines results from multiple domain controllers into a single report.
    • Cleans up temporary files after completion.
  • Usage:

    1. Update the domain controller variables $DC1 and $DC2 in the script.
    2. Specify the export file paths.
    3. Run the script to generate the report.

3. ADExportWithExcel.ps1

A more advanced script that exports user account details to an Excel workbook, organizing data by OUs and including users outside of the specified OUs.

  • Features:

    • Supports multiple domain controllers for redundancy.
    • Exports user details for specific OUs into separate Excel worksheets.
    • Filters and exports users outside the defined OUs into an "Other" worksheet.
    • Uses the ImportExcel module for creating Excel files.
  • Usage:

    1. Install the ImportExcel module by running:
      Install-Module -Name ImportExcel -Scope CurrentUser
    2. Update the $DCs variable with your domain controllers.
    3. Define the desired OUs and their corresponding worksheet names in the $OUs variable.
    4. Specify the output Excel file path.
    5. Run the script to generate the Excel report.

Prerequisites

  1. Active Directory Module:

    • Ensure the Active Directory module is installed on the machine running the scripts.
    Install-WindowsFeature -Name RSAT-AD-PowerShell
  2. ImportExcel Module (for ADExportWithExcel.ps1):

    • Install the ImportExcel PowerShell module:
      Install-Module -Name ImportExcel -Scope CurrentUser
  3. Required Folders:

    • Create the necessary directories:
      • C:\Scripts for temporary files.
      • C:\CSVReports for final output files.

Running the Scripts

  1. Open PowerShell with administrative privileges.
  2. Navigate to the directory containing the script.
  3. Run the desired script:
    .\ScriptName.ps1

Outputs

  • ADUserExport.ps1 and ADComputerExport.ps1:

    • CSV files containing the exported data, saved in the C:\CSVReports folder.
  • ADExportWithExcel.ps1:

    • An Excel workbook (ADExport.xlsx) with multiple worksheets, saved in the C:\CSVReports folder.

Contribution

Feel free to submit issues or pull requests if you encounter any bugs or have ideas for improvement!


License

This project is licensed under the MIT License. See the LICENSE file for details.

About

This repository contains PowerShell scripts to export Active Directory (AD) user and computer information.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published