Moving a user between two local groups
hi
in windows 7, when try move user between 2 local groups these 2 statements:
([adsi] "winnt://([environment]::machinename)/$groupname,group").add( ([adsi] "winnt://$([environment]::machinename)/$username,user").adspath ) ([adsi] "winnt://([environment]::machinename)/$oldgroupname,group").remove( ([adsi] "winnt://$([environment]::machinename)/$username,user").adspath )
the following error written: "exception retrieving member" add ":" can not find network path."
where mistake?
thanks
bye
balubeto
you missing $ sign in in first subexpression (e.g '$([environment]::machinename)')
you can use $env:computername instead, expandable inside strings , doesn't require sub-expression syntax.
([adsi] "winnt://$env:computername /$groupname,group").add( ([adsi] "winnt://$env:computername /$username,user").adspath )
shay levy [mvp]
http://blogs.microsoft.co.il/blogs/scriptfanatic
powershell toolbar
Windows Server > Windows PowerShell
Comments
Post a Comment