Windows Vista Forums

MakeMeAdmin.ps1
  1. #1


    Staffan Gustafsson Guest

    MakeMeAdmin.ps1

    Hi,

    Here's a dirty version of a powershell variant of Aaron Margosis
    MakeMeAdmin.cmd
    (http://blogs.msdn.com/aaron_margosis...4/193721.aspx).

    It uses get-credential and Process.Start instead of runas.



    All suggestions for improvements are welcome.

    Regards,

    /Staffan





      My System SpecsSystem Spec

  2. #2


    Alex K. Angelopoulos [MVP] Guest

    Re: MakeMeAdmin.ps1

    Can you repost with a .txt addition on the end of that extension? It appears
    to be automatically blocked by OE, and I'm not quite up to base64decoding
    the message source this morning.


    "Staffan Gustafsson" <staffan._less_spam_gustafsson@home.se> wrote in
    message news:eCTgM9t4GHA.3556@TK2MSFTNGP02.phx.gbl...
    > Hi,
    >
    > Here's a dirty version of a powershell variant of Aaron Margosis
    > MakeMeAdmin.cmd
    > (http://blogs.msdn.com/aaron_margosis...4/193721.aspx).
    >
    > It uses get-credential and Process.Start instead of runas.
    >
    > All suggestions for improvements are welcome.
    >
    > Regards,
    >
    > /Staffan
    >
    >




      My System SpecsSystem Spec

  3. #3


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    Re: MakeMeAdmin.ps1

    param (
    [string] $user
    )


    function SuPowershell($domain, $user, $params=""){
    $SuAccount = get-credential "$domain\$user"
    if (!$SuAccount){
    return
    }
    $StartInfo = new-object System.Diagnostics.ProcessStartInfo
    $StartInfo.FileName = "$pshome\powershell.exe"
    $StartInfo.Domain = split-path $SuAccount.UserName
    $StartInfo.UserName = split-path -leaf $SuAccount.UserName
    $StartInfo.Password = $SuAccount.Password
    $StartInfo.LoadUserProfile = $true
    $StartInfo.UseShellExecute = $false
    $StartInfo.Arguments = $params
    $StartInfo.WorkingDirectory = (get-location).Path
    [System.Diagnostics.Process]::Start($StartInfo)
    }

    $admin = "Administrator"
    $thisScript = $myInvocation.MyCommand.Definition
    $powershell = "$pshome\powershell.exe"
    $group="Administrators"

    if (!$user){
    $domain = $env:UserDomain
    $currentUser = $env:Username
    SuPowershell $env:ComputerName $admin "`"& `'$thisscript`'
    $domain\$currentUser`""
    }
    else {
    $runasdomain = $(split-path $user)
    $runasUser = $(split-path -leaf $user)

    #Running as admin
    net localgroup $group $user /ADD
    SuPowershell $runasdomain $runasUser
    net localgroup $group $user /DELETE
    }

    --
    greetings
    dreeschkind

    "Alex K. Angelopoulos [MVP]" wrote:

    > Can you repost with a .txt addition on the end of that extension? It appears
    > to be automatically blocked by OE, and I'm not quite up to base64decoding
    > the message source this morning.
    >
    >
    > "Staffan Gustafsson" <staffan._less_spam_gustafsson@home.se> wrote in
    > message news:eCTgM9t4GHA.3556@TK2MSFTNGP02.phx.gbl...
    > > Hi,
    > >
    > > Here's a dirty version of a powershell variant of Aaron Margosis
    > > MakeMeAdmin.cmd
    > > (http://blogs.msdn.com/aaron_margosis...4/193721.aspx).
    > >
    > > It uses get-credential and Process.Start instead of runas.
    > >
    > > All suggestions for improvements are welcome.
    > >
    > > Regards,
    > >
    > > /Staffan
    > >
    > >

    >
    >
    >


      My System SpecsSystem Spec

  4. #4


    Jacques Barathon [MS] Guest

    Re: MakeMeAdmin.ps1

    "Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> a écrit dans le message
    de news: e00zbNw4GHA.3964@TK2MSFTNGP04.phx.gbl...
    > Can you repost with a .txt addition on the end of that extension? It
    > appears to be automatically blocked by OE, and I'm not quite up to
    > base64decoding the message source this morning.


    You could also have temporarily turned blocking off (tools > options >
    security).

    Jacques


      My System SpecsSystem Spec

  5. #5


    Alex K. Angelopoulos [MVP] Guest

    Re: MakeMeAdmin.ps1

    Yeah, but I'm lazy.
    "Jacques Barathon [MS]" <jbaratho@online.microsoft.com> wrote in message
    news:eN5AUve5GHA.1252@TK2MSFTNGP04.phx.gbl...
    > "Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> a écrit dans le message
    > de news: e00zbNw4GHA.3964@TK2MSFTNGP04.phx.gbl...
    >> Can you repost with a .txt addition on the end of that extension? It
    >> appears to be automatically blocked by OE, and I'm not quite up to
    >> base64decoding the message source this morning.

    >
    > You could also have temporarily turned blocking off (tools > options >
    > security).
    >
    > Jacques




      My System SpecsSystem Spec

MakeMeAdmin.ps1 problems?