Month June 2018

Export local Active Directory information with PowerShell

Need to get a list of users in your domain? Or perhaps an inventory list of computers, or security groups? PowerShell is your friend! 🤝 Requirements and installation For first time and one-time setup you need to do the following: Download Remote Server Administration Tools for Windows 10 from Microsoft and install it. Make sure you choose the one appropriate for your operating system. In Windows run OptionalFeatures.exe and turn on Remote Server Administration Tools. In PowerShell you will have to run Import-Module ActiveDirectory. Usage Here are some common use cases. If you want more you can check out the official documentation. Export all users in AD with all attributes to a csv file. Make sure you Set-Location -Path or cd to the export path first. Export users of a specific organizational unit: If your domain is adatum.local then you should write DC=adatum,DC=local. For some strange reason the list of OU’s and DCs must be listed in a reverse order like this: But we could make it tidier by setting the list of OU and DC as variables. We can also make a variable with attributes. This makes it easier to change or adapt the script to different tasks. Export users that are actually human employees A lot of times you might have some service-accounts, test accounts or similar. If you just want to export a list of actual employees you can filter the results by using any attribute such as the employee number or employeeID. Get all disabled users that have an employee number Export memberships of users with employee number Find all employees with employee number and export their respective memberships to individual text files. Export all attributes of users with employee number Find all employees with employee number and export their all their respective attributes to individual […]