Unfortunately the OU names are not always unique in my case.

Querying by user would be an interesting idea.  However, I don’t always know of 
a user in the OU, so that won't work for my scenario.

The problem I am working on solving is that I have some scripts that request as 
input the canonical name since my previous scripts were designed with this (the 
Quest cmdlets offered this and I am attempting to remove my dependence on 
them).  And in other cases, the canonical name is in a CSV file that is read in 
as part of the script.  My goal is to convert these scripts to no longer use 
the Quest cmdlets, but still allow the scripts to function as they once did for 
both the operator inputted items as well as data from CSV files by accepting 
canonicalname paths (the operators prefer the canonical names too since it is 
easier to read).

It appears that I may just need to either use the piped query or string 
manipulation methods, or switch all of the inputs (human and CSV files) to use 
DNs.

Thanks,

-Aakash Shah

From: [email protected] [mailto:[email protected]] On 
Behalf Of Jeremy Brown
Sent: Thursday, November 13, 2014 5:47 AM
To: [email protected]
Subject: Re: [powershell] RE: Search For OU Using Filter With CanonicalName in 
AD

CanonicalName is a constructed attribute.  That means the attribute is built 
when asked for it.  Because of this you can't use it in a filter.  Are you 
querying for unique OU names?  Is there a way you can limit.  What if you did 
something like query for an individual user/group that would be a child and 
then grab the parent OU's DN?  I'm not sure how you are trying to use this yet. 
 What is the problem you are trying to solve?



On Wed, Nov 12, 2014 at 11:50 PM, Aakash Shah 
<[email protected]<mailto:[email protected]>> wrote:
Thanks for the information.  I had come across that but was hoping there was a 
simpler way.  However, it appears that there may not be.

If anyone has any other tricks/shortcuts that they’ve used for this scenario, 
please let us know.

Thanks,

-Aakash Shah

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]>] 
On Behalf Of Isaac Holmes
Sent: Wednesday, November 12, 2014 8:19 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: [powershell] RE: Search For OU Using Filter With CanonicalName in 
AD

http://windowsitpro.com/active-directory/translating-active-directory-object-names-between-formats


On Wed, Nov 12, 2014 at 11:02 PM, Damien Solodow 
<[email protected]<mailto:[email protected]>> wrote:
Perhaps something like this: http://poshcode.org/512http://poshcode.org/512 ?

DAMIEN SOLODOW
Systems Engineer
317.447.6033<tel:317.447.6033> (office)
317.447.6014<tel:317.447.6014> (fax)
HARRISON COLLEGE
________________________________
From: [email protected]<mailto:[email protected]> 
[[email protected]<mailto:[email protected]>] on 
behalf of Aakash Shah [[email protected]<mailto:[email protected]>]
Sent: Wednesday, November 12, 2014 10:48 PM
To: [email protected]<mailto:[email protected]>

Subject: [powershell] RE: Search For OU Using Filter With CanonicalName in AD

If I have the canonical name “domain.com/OU”, I am looking for a way to convert 
this into its corresponding DN value of  “OU=OU,DC=domain,DC=com”.  I plan to 
then use this to feed other cmdlets like Get-ADUser where the -SearchBase 
parameter appears to expect a DN value.

In my earlier email, I was attempting to search AD for the canonical name using 
the “-Filter” parameter in Get-ADOrganizationalUnit since it appears to have 
CanonicalName as an attribute, but I was unsuccessful.

My apologies for the confusion.

Thank you,

-Aakash Shah

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]>] 
On Behalf Of Michael B. Smith
Sent: Wednesday, November 12, 2014 7:27 PM
To: [email protected]<mailto:[email protected]>
Subject: [powershell] RE: Search For OU Using Filter With CanonicalName in AD

I don’t understand what you are asking for. Please give an example…

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Aakash Shah
Sent: Wednesday, November 12, 2014 9:59 PM
To: [email protected]<mailto:[email protected]>
Subject: [powershell] Search For OU Using Filter With CanonicalName in AD

Is there a clean/efficient way to filter for a canonical name in AD?  I tried 
the following but it did not work:

Get-ADOrganizationalUnit -Filter 'CanonicalName -eq 
"domain.com/OU<http://domain.com/OU>"' -Properties 'CanonicalName'

When I looked up other solutions, I found some sources where the string is 
parsed and manually pieced together as a DN entry, but I would like to avoid 
that preferably.  I was able to previously do this with the Quest cmdlets but I 
am working on moving away from them and am trying to find equivalent 
approaches, if possible.

I can pipe Get-ADOrganizationalUnit to a Where cmdlet to then do a search, but 
it is much slower:

Get-ADOrganizationalUnit -Filter * -Properties 'CanonicalName' | Where-Object 
{$_.CanonicalName -eq 'domain.com/OU<http://domain.com/OU>'}

Or, if anyone has information on using built in commands to convert a canonical 
name to a DN value, that would also be appreciated (the solutions I found also 
manually pieced each block together).

Thanks,

-Aakash Shah


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1



--

Isaac Holmes
IT Engineering Specialist

University of Notre Dame
320 IT Center
Notre Dame, IN 46556

(574) 631-3254<tel:%28574%29%20631-3254>

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1



--
Regards,
Jeremy Brown
ITECS Systems
NCSU

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to