Good morning. What I am trying to accomplish is easier said than done. With the code below, I return the following:
Group is owned by: @{samaccountname=aduser1}
Group is owned by: @{samaccountname=aduser2}
Here's the code:
$GroupList = get-content "Z:\text.txt"
ForEach($Entry in $GroupList){
$SubGroups = @()
$AllMembers = @()
$strGroupOwner = Get-ADGroup -identity $Entry -Properties ManagedBy | select managedby
$strOwnerName = get-aduser -identity $strGroupOwner.managedby -properties samaccountname |select samaccountname
"Group is owned by: " + $strOwnerName
I simply need to remove '@{samaccountname=' and the '}' at the end from my string $strOwnerName before passing it through to the next step to make my resume something closer to:
Group is owned by: aduser1
Group is owned by: aduser2
All I was able to find on Google was removing 'White Space'. Any help or reading material would be most appreciated.
Thanks!