Groups > Microsoft > Windows PowerShell > Re: MakeMeAdmin.ps1




Re: MakeMeAdmin.ps1

Re: MakeMeAdmin.ps1
Thu, 28 Sep 2006 09:35:56 -040
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/archive/2004/07/24/193721.aspx).
>
> It uses get-credential and Process.Start instead of runas.
>
> All suggestions for improvements are welcome.
>
> Regards,
>
> /Staffan
>
> 

Post Reply
MakeMeAdmin.ps1
Thu, 28 Sep 2006 11:20:08 +020
Hi,

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

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

All suggestions for improvements are welcome.

Regards,

/Staffan 


begin 666 MakeMeAdmin.ps1
M<&%R86T@* T*("
@(%MS=')I;F==("1U<V5R#0HI#0H-"@T*9G5N8W1I;VX@
M4W50;W=E<G-H96QL*"1D;VUA:6XL("1U<V5R+"
D<&%R86US/2(B*7L-"B @
M(" D4W5!8V-O=6YT(#T@9V5T+6-R961E;G1I86P@(B1D;VUA:6Y<)'5S97(B
M#0H@(" @:68@*"$D4W5!8V-O=6YT*7L-"B @(" @("
@<F5T=7)N#0H@(" @
M?0T*("
@("13=&%R=$EN9F\@/2!N97<M;V)J96-T(%-Y<W1E;2Y$:6%G;F]S
M=&EC<RY0<F]C97-S4W1A<G1);F9O#0H@("
@)%-T87)T26YF;RY&:6QE3F%M
M92 ]("(D<'-H;VUE7'!O=V5R<VAE;&PN97AE(@T*("
@("13=&%R=$EN9F\N
M1&]M86EN(#T@<W!L:70M<&%T:"
D4W5!8V-O=6YT+E5S97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=R;W5P("1U<V5R("]!1$0-"B @("!3
M=5!O=V5R<VAE;&P@("1R=6YA<V1O;6%I;B
D<G5N87-5<V5R#0H@(" @;F5T
C(&QO8V%L9W)O=7 @)&=R;W5P("1U<V5R("]$14Q%5$4-"GT`
`
end
Post Reply
Re: MakeMeAdmin.ps1
Thu, 28 Sep 2006 12:35:02 -070
param (
    [string] $user
)


function SuPowershell($domain, $user, $params=""){
    $SuAccount = get-credential "$domain\$user"
    if (!$SuAccount)
    $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/archive/2004/07/24/193721.aspx).
> >
> > It uses get-credential and Process.Start instead of runas.
> >
> > All suggestions for improvements are welcome.
> >
> > Regards,
> >
> > /Staffan
> >
> > 
> 
> 
Post Reply
Re: MakeMeAdmin.ps1
Mon, 2 Oct 2006 08:27:20 +0200
"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 
Post Reply
Re: MakeMeAdmin.ps1
Wed, 4 Oct 2006 10:22:15 -0400
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 

Post Reply
about | contact