I'm working on some Powershell scripts to allow me to change local admin rights without having to login to the PC and go into Computer Management to change and logoff/logon the user.
I found this script on the web, didn't write it myself.
This will work if I run it on my local PC, and I have Local Admin rights on my PC and on the PC I'm trying to make the change to. I am getting a "The network path was not found." error pointing to the line
Since I have LA rights on both PCs, it shouldn't matter that it isn't my PC, should it?
I found this script on the web, didn't write it myself.
Code:
$domain = "domain"
$strComputer = "user-pc"
$username = "username"
$computer = [ADSI]("WinNT://" + $strComputer + ",computer")
$computer.name
$Group = $computer.psbase.children.find("administrators")
$Group.name
function ListAdministrators
{$members= $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
$members}
ListAdministrators
$Group.Add("WinNT://" + $domain + "/" + $username)
ListAdministrators
This will work if I run it on my local PC, and I have Local Admin rights on my PC and on the PC I'm trying to make the change to. I am getting a "The network path was not found." error pointing to the line
Code:
$Group = $computer.psbase.children.find("administrators")
Since I have LA rights on both PCs, it shouldn't matter that it isn't my PC, should it?