We are performing an audit of different networks and need to distinguish between domains. The code I currently use will export to .csv but just uses the title I choose. What I need is for it to automatically name the .csv file with the domain name in it.
Below is my current code:
Import-Module ActiveDirectory
Get-ADObject -filter 'objectclass -eq "user"' -properties CN,DisplayName,Discription | select | export-csv -NoTypeInformation "c:\ADUsers.csv"
(gwmi win32_computersystem).domainjust put it in a variable and use it in your export-csv statement