header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
adding users to local admin group
Last Post 23 Jun 2010 07:19 AM by thalesdias. 0 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
thalesdiasUser is Offline
New Member
New Member
Posts:1
Avatar

--
23 Jun 2010 07:19 AM
    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)}

    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer