Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: MakeMeAdmin.ps1

27 views
Skip to first unread message

Alex K. Angelopoulos [MVP]

unread,
Sep 28, 2006, 9:35:56 AM9/28/06
to
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_...@home.se> wrote in
message news:eCTgM9t4...@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
>
>


dreeschkind

unread,
Sep 28, 2006, 3:35:02 PM9/28/06
to
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

Jacques Barathon [MS]

unread,
Oct 2, 2006, 2:27:20 AM10/2/06
to
"Alex K. Angelopoulos [MVP]" <a...@online.mvps.org> a écrit dans le message
de news: e00zbNw4...@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

Alex K. Angelopoulos [MVP]

unread,
Oct 4, 2006, 10:22:15 AM10/4/06
to
Yeah, but I'm lazy. ;)
"Jacques Barathon [MS]" <jbar...@online.microsoft.com> wrote in message
news:eN5AUve5...@TK2MSFTNGP04.phx.gbl...
0 new messages