Windows Sudo like command?

GT98

[H]ard|Gawd
Joined
Aug 29, 2001
Messages
1,256
I know about runas command, but is there a true sudo command in the windows command prompt that you can run that would give you temp admin rights (if you enter the admin password) if your logged into a standard windows account?
 

schizrade

Supreme [H]ardness
Joined
Feb 15, 2003
Messages
4,885
No there is not. Just they way the whole thing is setup.

Oh and stop using the cmd prompt and start using powershell. You will thank me in the log run.
 

Demon10000

Supreme [H]ardness
Joined
Aug 20, 2006
Messages
4,502
No there is not. Just they way the whole thing is setup.

Oh and stop using the cmd prompt and start using powershell. You will thank me in the log run.

...

Yes, you can use Runas to launch cmd.exe with an account that has administrative rights.

Or you can Tweak UAC to prompt you for authentication when you are trying to do something that has administrative rights.


In regards to powershell vs the command shell... eh... powershell is an amazing tool, but it's not obsoleting the command prompt. Depending on what you're doing, cmd.exe might be quicker, as powershell often likes to take it's time opening. Regardless of the shell, the question is really still the same...
 

schizrade

Supreme [H]ardness
Joined
Feb 15, 2003
Messages
4,885
...

Yes, you can use Runas to launch cmd.exe with an account that has administrative rights.

Or you can Tweak UAC to prompt you for authentication when you are trying to do something that has administrative rights.


In regards to powershell vs the command shell... eh... powershell is an amazing tool, but it's not obsoleting the command prompt. Depending on what you're doing, cmd.exe might be quicker, as powershell often likes to take it's time opening. Regardless of the shell, the question is really still the same...

Trust me, MS is slowly killing the CMD. A lot of commands are being replaced by PS cmdlets, and some of them even warn you to not use them when you run them in PS or tell you they are going away. I guess you only see this from the server side if you work in it daily. Try running dcpromo in server 2012 for example. You only options for promotion are through the GUI or through a PS console now.
 

schizrade

Supreme [H]ardness
Joined
Feb 15, 2003
Messages
4,885
Code:
 runas /u:DOMAIN\user command

That's about as close as you can get.

It kinda sucks.

I have a friend that works for the powershell dev team and she says it is the most requested feature from IT people/Powerusers.
 

Yossarian22

[H]ard|Gawd
Joined
Apr 27, 2009
Messages
1,793
Code:
 runas /u:DOMAIN\user command

That's about as close as you can get.

It kinda sucks.

I have a friend that works for the powershell dev team and she says it is the most requested feature from IT people/Powerusers.

I don't really use PS or Windows, but isn't there a way to alias similar to your terminal's .rc / configuration file under Powershell?
 

schizrade

Supreme [H]ardness
Joined
Feb 15, 2003
Messages
4,885
Yes, you can create a cmdlet to do this with a single command and save it to a PS profile.

A true sudo/su would be better.
 

devil22

2[H]4U
Joined
Jan 1, 2003
Messages
3,837
This is the one I use; basically just "sudo mycommand.exe" and you get a UAC prompt. I looked around at the relevant objects and methods a while back, I pretty sure you can make it so you just type a password within the console, if that's what you want instead. It also opens a new window, don't know if that can be remedied, never really thought about it before. Any way, if you use this, you would probably want to put it in your "c:\users\[username]\documents\windowspowershell\\Microsoft.PowerShell_profile.ps1" file that autoloads when you start powershell.


Code:
function sudo ([string]$file, [string]$arguments) {
$psi = new-object System.Diagnostics.ProcessStartInfo $file;
$psi.Arguments = $arguments;
$psi.Verb = "runas";
$psi.WorkingDirectory = get-location;
[System.Diagnostics.Process]::Start($psi);
}
 

GT98

[H]ard|Gawd
Joined
Aug 29, 2001
Messages
1,256
Thanks guys, speaking of powershell...is there any good primers on it?

I cut my teeth with DOS 5.0 back in the day, so the old commands are ingrained...I've used powershell a little bit when I was admin on Office 365 at my last job.
 

x509

2[H]4U
Joined
Sep 20, 2009
Messages
2,630
Thanks guys, speaking of powershell...is there any good primers on it?

I cut my teeth with DOS 5.0 back in the day, so the old commands are ingrained...I.

LOL. How about someone who started with CPM 2.2? :)
 

devil22

2[H]4U
Joined
Jan 1, 2003
Messages
3,837
Thanks guys, speaking of powershell...is there any good primers on it?

I cut my teeth with DOS 5.0 back in the day, so the old commands are ingrained...I've used powershell a little bit when I was admin on Office 365 at my last job.

Do you know C++, C# or VB, etc? It's pretty much like that, except you can type the statements into the command line, and it includes commands that are kinda command.exe like to make that kind of stuff easy. That said, my favorite book on powershell is "powershell in action". Free wise, there's this online book: http://blogs.technet.com/b/chitpro-...shell-course-book-available-for-download.aspx - and a few others too I think.
 

GT98

[H]ard|Gawd
Joined
Aug 29, 2001
Messages
1,256
LOL. How about someone who started with CPM 2.2? :)

How about Basic on a C64 :)

My first true computer was a Commadore 128, running in C64 mode 95% of the time.

Got my first PC clone in 1990 or so
 

GT98

[H]ard|Gawd
Joined
Aug 29, 2001
Messages
1,256
Do you know C++, C# or VB, etc? It's pretty much like that, except you can type the statements into the command line, and it includes commands that are kinda command.exe like to make that kind of stuff easy. QUOTE]


ugh I hate programming (outside of Cisco switches)....

thanks for the link though :)
 

x509

2[H]4U
Joined
Sep 20, 2009
Messages
2,630
Do you know C++, C# or VB, etc? It's pretty much like that, except you can type the statements into the command line, and it includes commands that are kinda command.exe like to make that kind of stuff easy. That said, my favorite book on powershell is "powershell in action". Free wise, there's this online book: http://blogs.technet.com/b/chitpro-...shell-course-book-available-for-download.aspx - and a few others too I think.

I just tried this link and i got a 404 on what I thought was the actual download page:
http://download.microsoft.com/download/4/7/1/47104ec6-410d-4492-890b-2a34900c9df2/Workshops-EN.zip

Anyone have a good link?
 
Top