Author Posts

February 28, 2018 at 8:24 am

Hi there.

I just wanted to write a really small and easy script but it doesn't seem to work 🙁

I simply just want to give local admin rights.

$computername=Read-Host "enter the computername"
$username=Read-Host "enter the user name you want to give access to (DOMAIN\username)"

Invoke-Command -ComputerName $computername -Command {Add-LocalGroupMember -Group Administratoren -Member $username }

when I only run the command without the parameters but with filled out values it works fine. As soon as I put in $username it doesn't work anymore and I get the following error message:

+ CategoryInfo : InvalidData: (:) [Add-LocalGroupMember], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand

February 28, 2018 at 8:40 am

In this post there is a script you maybe able to use to do this.

$DomainName = Read-Host "Domain name:"
$ComputerName = Read-Host "Computer name:"
$UserName = Read-Host "User name:"
$AdminGroup = [ADSI]"WinNT://$ComputerName/Administrators,group"
$User = [ADSI]"WinNT://$DomainName/$UserName,user"

February 28, 2018 at 8:52 am


$ps = "Windows PowerShell"
Invoke-Command -ComputerName S1 -ScriptBlock {
  Get-WinEvent -LogName $Using:ps

February 28, 2018 at 9:00 am

Hello Crovax,

thank you that's exactly what I needed!

yeah, now that I think about it, it seems logical. thanks 🙂