Answers for "add logged in user to local administrators group powershell site:www.reddit.com"

0

add logged in user to local administrators group powershell site:www.reddit.com

$LocalhostSession= New-PSSession -ComputerName localhost -Credential $mycreds 
$Arguments = @($username)
$sb= {Param ([string]$username); $de = [ADSI]"WinNT://$env:computername/administrators,group"; $de.psbase.Invoke("Add",([ADSI]"WinNT://domain.net/$username").path)}
Invoke-Command -ComputerName $env:COMPUTERNAME -Session $LocalhostSession  -ArgumentList $Arguments -ScriptBlock $sb
Posted by: Guest on February-10-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language