Jump to content

Output to _array


alan lim
 Share

Recommended Posts

How to make the following line to output to an array instead to a text file? The reason is if I output to a file, and at the end I have to delete it. Is quite troublesome. Thank you

runwait(@ComSpec & " /c" & "dsquery user "& '"ou=HR,dc=xxxx,dc=com"' & " -name" &" alan*")

Alan Lim

Link to comment
Share on other sites

To query the Active Directory you could use the ADFunctions UDF. This would solve this (and probably future) problems.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yes, it's possible. Something like this:

#include <adfunctions.au3>

Global $asUsers
_ADGetObjectsInOU($asUsers,"ou=HR,dc=xxxx,dc=com","(&(objectCategory=user)(name=alan*))",2,"name,description")
_ArrayDisplay($asUsers)

Each function in adfunctions.au3 has a description of the required parameters. The term "(&(objectCategory=user)(name=alan*))" is an ordinary LDAP query string. Documentation on how to build such strings can be found on the internet.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you for your replied.

I have copied your script and run it. The description still show nothing.

I have even remove the name and left the desciption, _ADGetObjectsInOU($asUsers,"ou=HR,dc=xxxx,dc=com","(&(objectCategory=user)(name=alan*))",2,"description"). The array don't show anything. This is the problem I have facing.

Link to comment
Share on other sites

Are you sure that the description field is filled in AD? Could you download the Active Directory Explorer from M$ (previous Sysinternals) and run it (no installation required, just run the exe) to check if there is a description?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 3 weeks later...

Yes, it's possible. Something like this:

#include <adfunctions.au3>

Global $asUsers
_ADGetObjectsInOU($asUsers,"ou=HR,dc=xxxx,dc=com","(&(objectCategory=user)(name=alan*))",2,"name,description")
_ArrayDisplay($asUsers)

Each function in adfunctions.au3 has a description of the required parameters. The term "(&(objectCategory=user)(name=alan*))" is an ordinary LDAP query string. Documentation on how to build such strings can be found on the internet.

I haven't gotten terribly far in my LDAP query studies, is there a way we can pull a schema attribute into that array? something like ,2,"name,lastLogin". The end goal is to pull this value and then run it against a last login calculator so I can disable inactive computer accounts.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...