Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Add domain user to local Administrators group of other

$
0
0

Not sure what the parameter problem is:

 

 

$ComputerName = 'testServer'
$LocalGroupName = 'administrators'
$domain = 'dom'
$user = 'tUser'
$Credential = Get-Credential vsi\diverso

Invoke-Command -ComputerName $ComputerName -Credential $Credential -ScriptBlock { param($ComputerName,$LocalGroupName,$domain,$user)
$de = [ADSI]"WinNT://$ComputerName/$LocalGroupName,group"
$de.psbase.Invoke("Add",([ADSI]"WinNT://$domain/$user").path)
} -ArgumentList $ComputerName,$LocalGroupName,$domain,$user

Exception calling "Invoke" with "2" argument(s): "Number of parameters specified does not match the expected number."
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodTargetInvocation
    + PSComputerName        : testServer.dom.com


Viewing all articles
Browse latest Browse all 6937

Trending Articles