Jump to content
Sign in to follow this  
EddardStark

Machine AD OU or "IfExist" regread?

Recommended Posts

EddardStark

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!

Share this post


Link to post
Share on other sites
failedtocompile

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

Share this post


Link to post
Share on other sites
somdcomputerguy

For Question 1 -

RegRead

StringCompare

Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
somdcomputerguy

Ya I guess, since OP just wants to search for text contained in a string. I didn't read the first post well enough..


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
EddardStark

Thanks guys. You gave me a few ideas and options that I can easily work from.

Share this post


Link to post
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
Sign in to follow this  

×