pseymour / MakeMeAdmin

Make Me Admin is a simple, open-source application for Windows that allows standard user accounts to be elevated to administrator-level, on a temporary basis.
https://makemeadmin.com/
GNU General Public License v3.0
391 stars 86 forks source link

Feature Request - Make Me Admin commands #115

Open tbcahill opened 7 months ago

tbcahill commented 7 months ago

Is there a way to add/remove admin permissions via CMD / Powershell commands. This would a great addion for power users

jwal-d-velop commented 7 months ago

You could just use something like this to get Administrator rights with PowerShell:

$source = @"
using System;
using System.ServiceModel;

namespace SinclairCC.MakeMeAdmin
{
    [ServiceContract(Namespace = "http://apps.sinclair.edu/makemeadmin/2017/10/")]
    public interface IAdminGroup
    {
        [OperationContract]
        void AddUserToAdministratorsGroup();
    }
}
"@

# Import the required .NET assemblies
Add-Type -TypeDefinition $source -ReferencedAssemblies System.ServiceModel
Add-Type -AssemblyName System.ServiceModel

# Load the required .NET assemblies
[System.Reflection.Assembly]::LoadWithPartialName("System.ServiceModel")

# Create a NetNamedPipeBinding object
$binding = New-Object System.ServiceModel.NetNamedPipeBinding

# Define the endpoint address
$endpointAddress = "net.pipe://localhost/MakeMeAdmin/Service"

# Create a channel factory to communicate with the service
$channelFactory = New-Object 'System.ServiceModel.ChannelFactory[SinclairCC.MakeMeAdmin.IAdminGroup]' -ArgumentList $binding, $endpointAddress

# Create a channel using the channel factory
$channel = $channelFactory.CreateChannel()

# Call the AddUserToAdministratorsGroup method on the channel
$channel.AddUserToAdministratorsGroup()

# Close the channel factory
$channelFactory.Close()
tbcahill commented 7 months ago

@jwal-d-velop, Thanks I'll give this a try

tbcahill commented 7 months ago

This worked nicely. thank you!

pseymour commented 7 months ago

Re-opening this, because it sounds like a good idea. Get-AdminRights or something?