When you use select-object, you're creating custom objects with whatever
properties you specify to select.
When you select just one property you get objects that only have one property,
but that property still needs to be referenced by its property name using the
same dot notation you'd use to specify one of multiple properties -
object.property.
See if this works better:
$GroupMem = (Get-Group "AD_GROUP").members | select DistinguishedName
ForEach ($Member in $GroupMem)
{
Write-output $member.distinguishedname
get-mailbox -id $member.distinguishedname
}
From: Kleciak, Clint D A7IT [mailto:[email protected]]
Sent: Thursday, November 04, 2010 2:39 PM
To: MS-Exchange Admin Issues
Subject: RE: Power Shell and Multi Valued Attribute
Revisited
I did not have any luck getting this working, when I run the following code:
/Start
$GroupMem = (Get-Group "AD_GROUP").members | select DistinguishedName
ForEach ($Member in $GroupMem)
{
Write-output $member
get-mailbox -id $member
}
/End
I get an error stating cannot convert
"@{DistinguishedName=CN=id,ou=users,dc=domain,dc=com}" value of type.
I am assuming because it is not a String Value and it has the
"@{DistinguishedName=". Any suggestions.
_______________________________________
Clint Kleciak
Infrastructure Engineer Mgr
CIGNA IT
[email protected]
1-860-226-1386
Confidential, unpublished property of CIGNA. Do not duplicate or distribute.
Use and distribution limited solely to authorized personnel. (c) Copyright 2010
CIGNA
From: Campbell, Rob [mailto:[email protected]]
Sent: Tuesday, October 26, 2010 4:12 PM
To: MS-Exchange Admin Issues
Subject: RE: Power Shell and Multi Valued Attribute
If you're doing multiple groups, you may want to do this:
$GroupMem = @((Get-Group "Name_Of_Group").members | select DistinguishedName)
ForEach ($Member in $GroupMem){
Do something
}
Otherwise, if it encounters a group with just one member it's not going to be
happy.
From: KenM [mailto:[email protected]]
Sent: Tuesday, October 26, 2010 2:27 PM
To: MS-Exchange Admin Issues
Subject: Re: Power Shell and Multi Valued Attribute
this should work, it will give you the users DN
$GroupMem = (Get-Group "Name_Of_Group").members | select DistinguishedName
ForEach ($Member in $GroupMem){
Do something
}
On Tue, Oct 26, 2010 at 3:14 PM, Kleciak, Clint D A7IT
<[email protected]<mailto:[email protected]>> wrote:
I am trying to modify settings of users in a group, I would like to run
something like
$GroupMem = Get-Group "Name_Of_Group"
ForEach ($_.Member in $GroupMem)
Do something
Only problem is "Member" is a multi valued attribute that includes all the
individual members. Does anyone know a way to work around that?
thanks
_______________________________________
Clint Kleciak
Infrastructure Engineer Mgr
CIGNA IT
[email protected]<mailto:[email protected]>
1-860-226-1386
Confidential, unpublished property of CIGNA. Do not duplicate or distribute.
Use and distribution limited solely to authorized personnel. (c) Copyright 2010
CIGNA
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe exchangelist
------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this email in error, please
immediately notify the sender by e-mail at the address shown. This email
transmission may contain confidential information. This information is intended
only for the use of the individual(s) or entity to whom it is intended even if
addressed incorrectly. Please delete it from your files if you are not the
intended recipient. Thank you for your compliance. Copyright 2010 CIGNA
==============================================================================
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe exchangelist
**************************************************************************************************
Note:
The information contained in this message may be privileged and confidential and
protected from disclosure. If the reader of this message is not the intended
recipient, or an employee or agent responsible for delivering this message to
the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify us immediately by
replying to the message and deleting it from your computer.
**************************************************************************************************
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe exchangelist
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe exchangelist
------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this email in error, please
immediately notify the sender by e-mail at the address shown. This email
transmission may contain confidential information. This information is intended
only for the use of the individual(s) or entity to whom it is intended even if
addressed incorrectly. Please delete it from your files if you are not the
intended recipient. Thank you for your compliance. Copyright 2010 CIGNA
==============================================================================
**************************************************************************************************
Note:
The information contained in this message may be privileged and confidential
and
protected from disclosure. If the reader of this message is not the intended
recipient, or an employee or agent responsible for delivering this message to
the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify us immediately by
replying to the message and deleting it from your computer.
**************************************************************************************************
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe exchangelist