Powershell AD question

Soldato
Joined
18 Nov 2011
Posts
2,561
Location
Caddington
Hi Guys,

First time posting in this part of the forum but have a quick question that I cannot seem to find the answer for. I am trying to select the owner of an AD group via powershell and I can get the result using a fairly simple query

get-adgroup -identity "Group Name" -Properties Managedby |select managedby

But this is giving me

managedby
---------
CN=Lastname\, FirstName,OU=Info,OU=Users,OU=Accounts,OU=UK,OU=info,DC=info,DC=info

Is there a way to just return Lastname and Firstname from this? I have tried a split but cannot seem to get that working.
 
Man of Honour
Joined
20 Sep 2006
Posts
34,567
Code:
get-acl groupname | select-object owner

Just replace groupname with what you want.

EDIT might not work on an AD group, don't have AD installed at home so can't test right now.
 
Last edited:

Bry

Bry

Associate
Joined
24 Jul 2005
Posts
1,374
Probably a much better way of doing this. But very quickly

$Group1=Get-ADGroup "Group Name" -properties managedby
$Group1.managedby | get-aduser -properties Givenname, surname | select Surname, givenname
 
Soldato
OP
Joined
18 Nov 2011
Posts
2,561
Location
Caddington
Bry's suggestion worked perfectly and was simple enough that I should have come up with it myself. What I was doing yesterday I will never know.

Appreciate the help guys.
 
Back
Top Bottom