I want to export AD user list but my system in not in that Domain. I do have Admin permission. its 2008 AD. I know we can pull the list using dsquery / dsget or get-ADuser but all works when we are running this in same domain.
You may use the the following from an elevated command prompt:
runas /netonly /user:domain\adminUsername cmd.exe
(Adding a host entry for the domain name may help/be necessary)
Then run your dsquery command:
dsquery * domainroot -filter "(&(objectCategory=person)(objectClass=user))" -attr samAccountName distinguishedName whenCreated whenChanged lastLogonTimestamp
It's also possible to connect with AD Users and Computers from the system that is not in the domain.
Run the following from an elevated command prompt:
runas /netonly /user:domain\adminUsername "mmc dsa.msc /server:domainControllerName"