Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PowerShell script passing distinguishedName

Posted on 2014-09-15
3
Medium Priority
?
383 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

660 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