|
Re: Collecting information from Active Directory $root = {ADSI]"LDAP://ou=workstations,dc=somedomain,dc=net"
$computers = $root.psbase.get_children()
$computers | ft distinguishedname,operatingsystem
Those attributes I used as an example, there are others available on
computers. Unfortunately, you will not find the last logged on user
stored in AD, its just not in the design. For that you would have to
enable auditing on the workstation, and look through the security logs.
The script above connects to a specific OU and enumerates the objects
inside. Things to add is a LDAP filter to search for computer objects(
like (objectcategory=computer)), and maybe starting at the rootDSE
instead of a child OU and using .findall() to find computers.
james pogran
Glenn Wilson wrote:
> Hello All,
>
> I need to get a list of all computers in our Active Directory and the user
> who last logged onto it. Has anyone got a sample script to help with this, or
> at least some parts of it.....
>
> Thanks in advance. |