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