Taking the script from: http://blogs.technet.com/b/heyscriptingguy/archive/2008/03/11/how-can-i-use-windows-powershell-to-add-a-domain-user-to-a-local-group.aspx
This does not work:
$objUser = [ADSI]("WinNT://mydomain/myusername")
$objGroup = [ADSI]("WinNT://REMOTEPC/Administrators")
$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)I get the following error:
Exception calling "Invoke" with "2" argument(s): "The network path was not found. "At line:1 char:24 + $objGroup.PSBase.Invoke <<<< ("Add",$objUser.PSBase.Path) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
This DOES work:
$objUser = [ADSI]("WinNT://mydomain/myusername")
$objGroup = [ADSI]("WinNT://./Administrators")
$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)According the blog post both should work seamlessly.
Am I missing something?