Solved

PowerShell script passing distinguishedName

Posted on 2014-09-15
3
349 Views
Last Modified: 2014-09-18
I want to run this script to set an AD attribute:

$ad = [adsi]"LDAP://CN=\#SomeObject,OU=SomeOU,DC=SomeDC,DC=SomeDC";

$ad.msExchDelegateListLink.Clear();
$ad.SetInfo();

$list = Get-ADGroupMember "SomeGroup" -recursive | Select distinguishedName;

foreach ($group_name in $list)
{
	#this works as expected and returns a distinguishedName
	#write-output $group_name

	#this doesn't work:
	$ad.msExchDelegateListLink.Add($group_name)

	$ad.SetInfo();
}

Open in new window


It works, when I replace $group_name with a static distinguishedName. Unfortunately it fails in the above version:

Ausnahme beim Aufrufen von "Add" mit 1 Argument(en):  "Unbekannter Fehler
"
Bei C:\Users\Admin_Knell\test.ps1:11 Zeichen:32
+     $ad.msExchDelegateListLink.Add <<<< ($group_name)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Open in new window


Did I miss something?

Thanks and best regards
Chris
0
Comment
Question by:mbwjk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 40322794
Change line 6 to
$list = Get-ADGroupMember "SomeGroup" -recursive | Select -expand distinguishedName;

Open in new window

0
 

Author Comment

by:mbwjk
ID: 40331345
Perfect - thanks a lot!

Best regards
Chris
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40331352
You are welcome!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS - Powershell 7 80
Powershel lto remove users from group 15 41
powershell and select-string regex multi line 8 44
Powershell script to pagefile.sys 3 74
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question