Mark Minasi's Tech Forum
Register Calendar Latest Topics Chat
 
 
 


Reply
  Author   Comment  
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #1 
So I am a but stumped on this and am sure I am missing something simple...

When I use 

Code:
Get-ADOrganizationalUnit -LDAPFilter '(gPLink=*9AB6715A-CD28-4A33-8E7F-GH41I11JKL41*)'  


I get the desired results.

But if I

Code:
$Stuff = Get-Content C:\Temp\List.txt

$Stuff | Get-ADOrganizationalUnit -LDAPFilter '(gPLink=$_)'


Or

Code:

$Stuff | Get-ADOrganizationalUnit -LDAPFilter '(gPLink=$($_))'


It doesnt work.  All I want is the GUID and its DistinguishedName



__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #2 
I got it working...

Code:

PS C:\> $Stuff | Foreach{Get-ADOrganizationalUnit -LDAPFilter "(gPLink=*$_*)"} | Select Name,DistinguishedName,ObjectGUID

__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
gpoguy

Avatar / Picture

New Friend (or an Old Friend who Built a New Account)
Registered:
Posts: 50
Reply with quote  #3 
Yea, Tim, sorry for the delay. The GP module does a lousy  job of handling the pipeline, as you've seen [smile]. I was going to suggest foreach...
__________________
Darren Mar-Elia
MS-Group Policy MVP
Founder--SDM Software (https://sdmsoftware.com)
Need Group Policy Training? Check out my Group Policy Fundamentals course: http://pluralsight.com/courses/group-policy-fundamentals
0
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #4 
Thanks Darren!   Delay is NOT ever a problem I appreciate the help.

Another question,

Again this may be simple but I would like each $_ to appear on the same line as the Name, DistinguishedName and ObjectGUID

Its as if the $_ is not being passed into the Select

Example - 

$Stuff | Foreach{Get-ADOrganizationalUnit -LDAPFilter "(gPLink=*$_*)"} | Select Name,@{l="UID";e={$_}},DistinguishedName,ObjectGUID


I am also getting more information on what exactly is needed here. I am presuming that for what ever reason they only have a UID and want to get info on it. Im thinking there may be better cmdlets to use if this is the case.


Thanks Again Darren!!




__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #5 

Thanks Darren! Delay is NOT ever a problem I appreciate the help.

Another question,

Again this may be simple but I would like each $_ to appear on the same line as the Name, DistinguishedName and ObjectGUID

Its as if the $_ is not being passed into the Select

Example -

Code:
$Stuff | Foreach{Get-ADOrganizationalUnit -LDAPFilter "(gPLink=*$_*)"} | Select Name,@{l="UID";e={$_}},DistinguishedName,ObjectGUID

 

I am also NOT getting back results from all of the UIDs.  No errors just no returned values.  If I have 30 I may see 15...

I am also gettng more information on what exactly is needed here. I presume that for whatever reason they only have the UID and want to identify what and where.

I would think if that is the case there would be a better cmdlet to use which would provide all the information needed.

I will post once I get some clarification.

 

Thank You Darren!!

 


__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
wkasdo

Avatar / Picture

Administrator
Registered:
Posts: 188
Reply with quote  #6 
What is "UID"?

One problem here is that the first $_ is an item from the $stuff array, but the second $_ in the pipeline is an OU object.

Another potential problem is that the OU result set may be empty (GPO not linked).

A third is that you are not checking for the Domain or Site objects.


__________________
[MSFT]; Blog: https://blogs.technet.microsoft.com/389thoughts/
0
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #7 
What is "UID"? -- "I am trying to run following command which shows OUs linked to GPO gpo is referenced by UID."  

One problem here is that the first $_ is an item from the $stuff array, but the second $_ in the pipeline is an OU object.  -- Exactly!!  I tried using a Foreach($Thing in $Stuff){$UID = $Thing
Do stuff
}   That didnt work either...

Another potential problem is that the OU result set may be empty (GPO not linked).  -- Thats what I am thinking as well...  Getting more details on what their doing and why.

A third is that you are not checking for the Domain or Site objects. --  They are working on specific GPs via their UID.

I'm still trying to find out exactly what they are doing and why.


__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
gpoguy

Avatar / Picture

New Friend (or an Old Friend who Built a New Account)
Registered:
Posts: 50
Reply with quote  #8 
Tim-
What information are you trying to receive? Are you trying to ask--given a GPO, where is it linked?

Darren

__________________
Darren Mar-Elia
MS-Group Policy MVP
Founder--SDM Software (https://sdmsoftware.com)
Need Group Policy Training? Check out my Group Policy Fundamentals course: http://pluralsight.com/courses/group-policy-fundamentals
0
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #9 
Quote:
Originally Posted by gpoguy
Tim-
What information are you trying to receive? Are you trying to ask--given a GPO, where is it linked?

Darren


I believe so,,, from the emails they have the UID and want the DistinguishedName with the UID listed on the same line.

I still have not been given an answer to what they are trying to do so I am going to leave this alone until further notice...

Thanks Everyone!!!

__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
gpoguy

Avatar / Picture

New Friend (or an Old Friend who Built a New Account)
Registered:
Posts: 50
Reply with quote  #10 
OK. If that is the question they are trying to ask, you can also do this, which is more straightforward:

[xml]$gpo = Get-GPOReport -Name "Default Domain Policy" -ReportType XML
$gpo.GPO.LinksTo

And, my GPMC PowerShell Module (https://sdmsoftware.com/gpoguy/free-tools/library/) has always had a cmdlet called Get-SDMGPLinks that can do the same thing.

Darren

__________________
Darren Mar-Elia
MS-Group Policy MVP
Founder--SDM Software (https://sdmsoftware.com)
Need Group Policy Training? Check out my Group Policy Fundamentals course: http://pluralsight.com/courses/group-policy-fundamentals
0
jsclmedave

Administrator
Registered:
Posts: 445
Reply with quote  #11 
Quote:
Originally Posted by gpoguy
OK. If that is the question they are trying to ask, you can also do this, which is more straightforward:

[xml]$gpo = Get-GPOReport -Name "Default Domain Policy" -ReportType XML
$gpo.GPO.LinksTo

And, my GPMC PowerShell Module (https://sdmsoftware.com/gpoguy/free-tools/library/) has always had a cmdlet called Get-SDMGPLinks that can do the same thing.

Darren


Excellent!  Thanks Darren!

__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.