Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

ADSI script not working for remote PCs

$
0
0

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?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>