HudRah
asked on
Modify Distribution Group Members (Scripting)
Hi, I am attempting to script the code presented in article RE: 3669 "Modify Distribution Group Members" to read in a file with DL names and then upgrade them populating the managed by field. I attempted to do this but get an error on the following line, if ran as part of script:
>>>
foreach($g in $groups) { $user = $g.user.tostring().substri ng($g.user .tostring( ).indexof( "\") + 1);
ERROR: You cannot call a method on a null-valued expression.
At C:\scripts\NEW\DL\NEW\DLmo dification -FORLIST-u _test.ps1: 32 char:50
+ foreach($g in $groups) { $user = $g.user.tostring <<<< ().substring($g.user.tostr ing().inde xof("\") + 1);
+ CategoryInfo : InvalidOperation: (tostring:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
>>>
When I run it manually, it runs fine. Am I missing something? Any Advice would be greatly appreciated.
Attached is my attempted script.
Thanks,
SCRIPT.txt
>>>
foreach($g in $groups) { $user = $g.user.tostring().substri
ERROR: You cannot call a method on a null-valued expression.
At C:\scripts\NEW\DL\NEW\DLmo
+ foreach($g in $groups) { $user = $g.user.tostring <<<< ().substring($g.user.tostr
+ CategoryInfo : InvalidOperation: (tostring:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
>>>
When I run it manually, it runs fine. Am I missing something? Any Advice would be greatly appreciated.
Attached is my attempted script.
Thanks,
SCRIPT.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.