Hi, i am starting to use some powershell scripts and would like your help to adjust this script, i want to add a user to the admin group of a remote computer, the script already does it, however i would to change the way i insert the user name and computer name, i dont know if it´s possible but the changes i wanna do is
when i run the script it will Popup a window asking the username and another one asking the computer After the end of script popup a window saying "user added succesfully" or in case of error show the error message.
is this possible to be done?
$domain = "domain" $strComputer = "computername" $username = "username"
$computer = [ADSI]("WinNT://" + $strComputer + ",computer") $computer.name
$Group = $computer.psbase.children.find("administrators") $Group.name
{$members= $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)} $members}
$Group.Add("WinNT://" + $domain + "/" + $username)
$members = @($group.psbase.Invoke("Members")) $members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
|