Open tbcahill opened 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()
@jwal-d-velop, Thanks I'll give this a try
This worked nicely. thank you!
Re-opening this, because it sounds like a good idea. Get-AdminRights or something?
Is there a way to add/remove admin permissions via CMD / Powershell commands. This would a great addion for power users