this post was submitted on 09 Feb 2024
113 points (94.5% liked)

Programming

17389 readers
146 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
all 35 comments
sorted by: hot top controversial new old
[–] abbadon420@lemm.ee 58 points 9 months ago (3 children)

It's weird that its just "sudo" and not "Get-Admin-Acces"

[–] rtxn@lemmy.world 26 points 9 months ago (1 children)

No, it really is super simple, just:

Set-HostElevatedPrivilege -SubstituteUser Administrator -Privilege [Microsoft.Automation.HostPrivilege]::new("Administrators", $(hostname)) -Credential $(Get-Credential) -Command "ping 1.1.1.1"
[–] Aatube@kbin.social 2 points 9 months ago

It's more complicated than that. It seems to be able to configurably block user input for sudo'd commands, retain the existing environment, ditch it and open a new window, and remember that you've sudo'd in the last minute or so.

[–] CaptPretentious@lemmy.world 23 points 9 months ago

It might just be an alias to a function similar to what you posted. Because like you can do curl but it really just calls invoke-webrequest, or ls for Get-ChildItem.

It is kind of weird that I took him this long to put this out though. I imagine a lot of people wrote their own version of this and it all probably very nearly the exact same.

[–] SilverShark@programming.dev 4 points 9 months ago (1 children)

Indeed. The name doesn't follow the conventions of other commands in Windows/Powershell at all. And it is inconsistente too. "sudo" stands for "super user do", but in Windows the notion of super user is called administrator. This will likely also cause confusion with people googling for "sudo" and getting to *nix related pages instead.

[–] abbadon420@lemm.ee 2 points 9 months ago

Nah, you can just google "windows+sudo" and look at if your results talk about unix or windows. And if they're post 2024

[–] SpaceNoodle@lemmy.world 50 points 9 months ago (1 children)

It took them just under half a century! Good job!

[–] testeronious@lemmy.world 9 points 9 months ago

astonishing work!

[–] mvirts@lemmy.world 37 points 9 months ago (1 children)

When are they going to add sudont? You know, the NT version of sudo 😹

[–] JWBananas@startrek.website 18 points 9 months ago

More like SudoExW

[–] IHeartBadCode@kbin.social 33 points 9 months ago

"Look what they need to mimic a fraction of our power!"

something, something Arch BTW

[–] rtxn@lemmy.world 23 points 9 months ago* (last edited 9 months ago)

FINALLY! It only took them WAY TOO MANY FUCKING YEARS! Good job catching up to literal decades-old practices, guys! How do you like living in the 1990s?

Man, I'll almost miss having to run a VNC session in parallel with WinRM to click on the UAC popup.

[–] joeldebruijn@lemmy.ml 19 points 9 months ago* (last edited 9 months ago)

Old saying still applies if something isnt working:

Linux: be root

Windows: reboot

[–] arthur@lemmy.zip 18 points 9 months ago
[–] NegativeLookBehind@kbin.social 14 points 9 months ago* (last edited 9 months ago)

Aww that’s cute, they’re trying to be big boy computers now

[–] leanleft@lemmy.ml 11 points 9 months ago

not the onion

[–] RedWizard@lemmygrad.ml 7 points 9 months ago

I've been using gsudo for a long time, its a game changer.

[–] ApathyTree@lemmy.dbzer0.com 6 points 9 months ago* (last edited 9 months ago) (2 children)

Legit didn’t realize until this news came out that windows didn’t have that same sort of “lawl, yes, I know what I’m doing and accept it might break my shit if I’m wrong” override access… but then I stopped using windows at 7 and only started again with 11 when my Linux beast died. (Temporary and migrating off already!)

I never really used cmd on windows, everything was gui… but I prefer terminal to gui on Linux (idk why, maybe just because it’s different and feels more in control. Also verbose logs are sexy).

[–] DV8@lemmy.world 6 points 9 months ago (2 children)

Command line stuff on Windows (server) is in a pretty decent state now, imo. It's not perfect but more and more is manageable with powershell. It took some time to really grok that you're basically always working with objects but I'm a big fan and now quite dislike having to deal with just "text" output when I do something in Linux. (Probably also because I need to do a lot less in it so I'm not used to it as much)

Personally again I also like the naming scheme much more than how it's done in bash. If I need to do something I don't know I can search the command by using logical words. E.g. I want to change the properties of a service but don't know the command by heart I can use

Get-Command service

And I'll get a list of all commands that contain the word service.

When it comes to admin privileges you simply have the privileges of the account you used to start the session, which has its' own dangers I suppose since it requires you to maintain account hygiene yourself.

[–] LPThinker@lemmy.world 4 points 9 months ago* (last edited 9 months ago) (1 children)

If you dig the structured output of powershell, you might want to check out Nushell. It’s a cross-platform shell that builds on powershell’s structured data approach but is much less verbose and, in my opinion, more intuitive than both powershell and Posix shells.

[–] DV8@lemmy.world 2 points 9 months ago

Thanks, will check that out.

[–] Kuinox@lemmy.world 3 points 9 months ago

You could do it, you just had to run your terminal as administrator.
Just right click the terminal, and "Run As Administrator".

[–] ITeeTechMonkey@lemmy.world 5 points 9 months ago (1 children)

This means I no longer have to use my workaround command that loads a new terminal window with admin privileges!

Now, I might not completely loathe using Windows at work.

[–] anothercatgirl@lemmy.blahaj.zone 4 points 9 months ago (1 children)

they should name it something else so searching for it doesn't conflict with unix sudo

[–] deadbeef79000@lemmy.nz 7 points 9 months ago

That's the point, embrace, extend, extinguish.

Or enshitify perhaps.

[–] anothercatgirl@lemmy.blahaj.zone 3 points 9 months ago (1 children)

the most common uses of sudo are: pacman -Syu and apt update && apt upgrade. Windows needs proper CLI for the Microsoft Store or else windows sudo is quite lame.

[–] lazynooblet@lazysoci.al 5 points 9 months ago (1 children)
[–] abbadon420@lemm.ee 3 points 9 months ago
[–] CCMan1701A@startrek.website 3 points 9 months ago

This is fine, but don't make disabling ads and other tracing hidden under sudo commands that no one is going to guess.

Knowing how windows works sudo isn't going to mean what we think it means. It'll be like sudo for some things, and admin sudo for other.

[–] spez_@lemmy.world 1 points 9 months ago

Windows is way ahead of the other operating systems. Not even gonna name them because they're worthless

[–] nyakojiru@lemmy.dbzer0.com 0 points 9 months ago (1 children)