Jump to content

Recommended Posts

Posted

I'm writing a script that would be greatly aided by be able to find the local machine's OU inside Active Directory. As far as I understand, Microsoft in its infinite wisdom did not put this attribute anywhere in the registry. I did find a key that has the machine's name along with the OU is a member of. My questions are:

1) Is it possible to kind of like an "IfExist" regread where I can search a specific registry key to see if it contains certain text?

2) Does anybody have a way to find out the OU of a machine by issuing commands through an AutoIT script?

Thanks a lot!

Posted (edited)

I'm writing a script that would be greatly aided by be able to find the local machine's OU inside Active Directory. As far as I understand, Microsoft in its infinite wisdom did not put this attribute anywhere in the registry. I did find a key that has the machine's name along with the OU is a member of. My questions are:

1) Is it possible to kind of like an "IfExist" regread where I can search a specific registry key to see if it contains certain text?

2) Does anybody have a way to find out the OU of a machine by issuing commands through an AutoIT script?

Thanks a lot!

Hello EddardStark

I am not an Autoit expert

but if you could run "dsquery computer domianroot -name computername" you maybe prompted for domain admin credentials

but you could i think incorporate that into your script such as

maybe??

#RequireAdmin

$computer = inputbox("computerName", "", "", "")

RunWait(@ComSpec & "/c " & 'dsquery computer domainroot -name' & " " & $computer & " " & '>' & @ScriptDir & '\query.txt',"",@SW_HIDE)

N.B. my code doesn't work as I am not that proficient in Autoit as of yet but maybe someone else can help with this code for you

Then export it to a file and read information after OU=

as a mentioned I am not an expert but i would think if you spent time on looking at some ideas i had you migth be able to come up with something >_< hehe

Edited by failedtocompile
Posted (edited)

The following script should give you the FQDN of the local computer. You can strip off the OU you need.

adfunctions.au3 can be found here.

#include <adfunctions.au3>
ConsoleWrite(_ADSamAccountNameToFQDN(@ComputerName & "{:content:}quot;) & @CRLF)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

 

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
×
×
  • Create New...