Solved

PowerShell script passing distinguishedName

Posted on 2014-09-15
3
325 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
  • 2
3 Comments
 
LVL 40

Accepted Solution

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

Open in new window

0
 

Author Comment

by:mbwjk
Comment Utility
Perfect - thanks a lot!

Best regards
Chris
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
You are welcome!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now