Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - ADSI Inconsistent behavior

Reply
 
Old 01-18-2007   #1 (permalink)
Dave


 
 

ADSI Inconsistent behavior

Hi,

Is anyone else getting inconsistent behavior when using ADSI via Powershell?
I'm trying to add users into groups. An example is:

$AllUsersGroup =
[ADSI]"LDAP://cn=AllUsers@testgroup,cn=users,dc=test,dc=com"
$AllUsersGroup.Member.Add("cn=user1,cn=users,dc=test,dc=com")
$AllUsersGroup.psbase.CommitChanges()

However, sometimes 0 is returned from the "Member.Add" line and sometimes
its a 1 (indicating the user has been added).

Any idea why it works sometimes and not others?

Thanks,
Dave.


My System SpecsSystem Spec
Old 01-19-2007   #2 (permalink)
Mark Ingalls


 
 

Re: ADSI Inconsistent behavior

Hello Dave,

> $AllUsersGroup =
> [ADSI]"LDAP://cn=AllUsers@testgroup,cn=users,dc=test,dc=com"
> $AllUsersGroup.Member.Add("cn=user1,cn=users,dc=test,dc=com")
> $AllUsersGroup.psbase.CommitChanges()
>
> However, sometimes 0 is returned from the "Member.Add" line and
> sometimes its a 1 (indicating the user has been added).


if i did my research correctly the page:

http://msdn2.microsoft.com/en-us/lib...ction.add.aspx

mentions that the return value of Add is the 0 based index of the item added.
it will throw an exception if it cannot add the user, so perhaps the return
code is not of much use?

thanks,
mark


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Solved Inconsistent Picture Preview Behavior General Discussion
inconsistent behavior PowerShell
Re: Inconsistent behavior with color rules Live Mail
Baffled by Inconsistent and Irrational Vista Backup Behavior Vista performance & maintenance
Smart-quote behavior: Is current behavior ideal? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46