[ / / / / / / / / / / / / / ] [ dir / acme / animu / arepa / caco / komica / vg / vichan / zoo ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): f54364c6ee16e1d⋯.png (8.07 KB, 256x256, 1:1, PowerShell_icon.png) (h) (u)

[–]

 No.990581>>990608 >>990941 >>990942 >>992427 [Watch Thread][Show All Posts]

>Objects as output instead of strings

>object-pipes

>Able to reference any .NET class, COM instance or public function from native DLLs by importing them

>Verb-noun syntax

>Well documented

>Powershell can expand parameters inline, so it's possible to write a function in Powershell without documentation and still have the parameters be discoverable

>Everything is a data structure

How is the UNIX shell better exactly?

 No.990589

It's not. It's software design for a 50 year old minicomputer, leaving you with the same limitations of that same computer, only its just faster.


 No.990608

>>990581 (OP)

>>Objects as output instead of strings

>>object-pipes

Therein lies the power, but while this is useful in the guts of a non-trivial script, it adds a bit of impedance when used in the midst of an otherwise text-only pipeline. It's not convenient to write adapter boilerplate to serialize and deserialize those objects, which I think is one of several reasons Linux users aren't installing Powershell Core. Also, the real applicability of Powershell lies in:

>Able to reference any .NET class, COM instance or public function from native DLLs by importing them

Unless you're already sipping the .NET cool-aid, Powershell is more of a hindrance than a help. Just use Nim/Python/whatever otherwise.


 No.990622>>990642

>Objects as output instead of strings

>object-pipes

>Able to reference any .NET class, COM instance or public function from native DLLs by importing them

>Verb-noun syntax

Don't see the benefit.

>Well documented

Same with bash.

>Powershell can expand parameters inline, so it's possible to write a function in Powershell without documentation and still have the parameters be discoverable

zsh does that.

>Everything is a data structure

bash support arrays.


 No.990642>>990715

>>990622

>Don't see the benefit

You prefer parsing strings to property accessors?


 No.990671>>991067

Bloat. sh is not that bad, it's mostly the surrounding tools that are bad.


 No.990713>>990930 >>991030

My old job required writing powershell scripts, it sucks ass. If they used Linux I could do everything twice as fast but powershell makes everything a pain. Also the autocomplete is shit


 No.990715>>990896 >>990932

File (hide): 52761805aacf5dd⋯.gif (721.15 KB, 500x281, 500:281, c92c00f04c4e1c626a24a9b5fb….gif) (h) (u)

>>990642

Please, explain.


 No.990720

Is PowerShell really a shell scripting language?


 No.990793>>991088

You do realise you can pipe out objects via Unix pipes right? Just pick a format and write programs that support it. Tons of stuff already passes around JSON, and if you want something lighter you can take advantage of Google's protocol buffers.


 No.990896>>990937 >>990940

>>990715

When you're piping shell processes which output text to the terminal, you'll often need to filter out unneeded text or use regexp groups to extract the bits you want before passing them to the next pipe. When your shell is piping objects instead of text, you can use property accessors and WHERE clauses to filter the data.

For example, if you wanted to change the CPU allocation of every currently running virtual machine on a Windows hypervisor, you could do it in a single line in Powershell:


Get-VM | Where { $_.State eq Running } | Stop-VM -Force -Passthru | Set-VM -ProcessorCount 4 -Passthru | Start-VM

To do the same thing in Linux with a text-based shell, you'd have to list the VM table (using virsh, qm, or some other VM manager), filter the rows which don't contain RUNNING in the status column using awk or sed, parse those lines for the Virtual Machine IDs, run the virtual machine manager again for each ID to stop them from running, run the virtual machine manager again for each ID to set the CPU count, and run the virtual machine manager yes again for each ID to start them back up.

On my Linux hypervisor, my script which automates these tasks (and uses proper BASH data structures to keep it as D.R.Y. as possible) is about 100 lines of painstakingly well-tested code. I would've saved many hours if Powershell were an option.


 No.990930

>>990713

As someone who knows PowerShell but no Bash, I feel the opposite way when someone throws a linux box my way at work.

If they just used IIS to host this shit, the script would have been done by now.


 No.990932

>>990715

loves this gif. thank you anon


 No.990937

>>990896

Definitely see the advantage, but it's always felt like more keystrokes than unix sh/bash/zsh, making it difficult for it to take the place of zsh for me

The extra keystrokes pay off for scripts, though, since you don't leave behind alphabet-soup option strings for the next guy to untangle.


 No.990940>>990943

>>990896

Your shit isn't very modular though, unlike plaintext pipes. The only problem of UNIX (and POSIX tools) is that there isn't a tabular interchange format for all tools; if only they had forbidden tabs and newlines in filenames, TSV could have been used to great avail.


 No.990941

>>990581 (OP)

>Verb-noun syntax

That's a bad thing, though. If you type 'tool-' and use completions, you'll get everything related to tool, but if type 'action-' and complete, you'll just get a bunch of unrelated stuff.


 No.990942

File (hide): 6d1c5f3aef87730⋯.jpg (78.52 KB, 720x706, 360:353, IMG_20181026_120030.jpg) (h) (u)

>>990581 (OP)

Might be better as a scripting language but it fucking blows as a terminal, granted I never used it for more than a few hours but the commands are long as shit for some reason.


 No.990943

>>990940

>Your shit isn't very modular

Uhhh it's extremely modular, what are you referring to exactly?


 No.991015

Shells are great. I wrote a basic shell once.

Parsing strings to parse strings to parse strings is just an amazing feeling.


 No.991023>>991081

Its concepts are far better. It's a great idea, but the syntax is shit. It's an annoying half-assed compromise between a shell and a scripting language, and you're almost always better off just using a better programming language that is a real programming language to do the same thing, like IronPython or IronRuby or something of the sort.

So Unix shell is better because it does what it's supposed to do, be a user-interactable shell where you can pipe data from anything to anything and it will usually work. You can grep for something without knowing its structure or having to worry about passing into the specifically right program to consume that type of data, as it's all text.

PowerShell is more powerful, but it's not a very good shell or a very good programming language, so it hits an awkward-to-use spot that's not particularly pleasant.


 No.991030

>>990713

>My job required me to use something I'm not familiar with. I'd be so much faster if I could use what I'm familiar with.

Wow.


 No.991067

>>990671

nope, sh is bad


 No.991081>>992622

>>991023

It fits a niche though. It's easy enough to learn and powerful enough where you don't need to learn a "real programming language" to become truly effective.


 No.991088>>992439 >>992622

>>990793

FreeBSD, though fucked in other ways, solved the output parsing problem correctly. You can tell its standard utilities like ls(1) to output machine-readable data in JSON, XML or HTML. It's better than actual opaque objects. jq (https://stedolan.github.io/jq/manual/) makes processing JSON from the shell a breeze.


 No.991767

Started learning this, and was able to trivialize a lot of server operations... is this the power of Microsoft®?


 No.992427>>992481

>>990581 (OP)

PowerShill is slow as fuck, it has shitty auto-completion and the naming conventions are counter-intuitive. Also, every time I try to run update-help, it can't finish for whatever reason. I think perl and ruby are better for scripting.


 No.992439

>>991088

JSON

XML

HTML

>no sqlite3


 No.992481

>>992427

>Get-* and Set-* are too difficult to remember

>Verb-Noun is too difficult to comprehend

Anon.

>Also, every time I try to run update-help, it can't finish for whatever reason.

Are you running at as admin? Does your admin account have access to the internet? If not you can download the help-files with your internet enabled account, and then update the help files from the locally saved versions with your admin account:


Save-Help -DestinationPath PATH
Update-Help -SourcePath PATH


 No.992485

WSO is my fav web shell

I usually find a way to upload a web shell and then pivot to a reverse shell using a netcat listener and /dev/tcp/ with bash or sh

or are you just talking about lame local shells?


 No.992622

>>991081

You described python.

>>991088

>jq

JQ is garbage if you don't know the structure of a json file. json.sh is better than jq for those instances.

gron is better than both

https://github.com/TomNomNom/gron




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
29 replies | 2 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / acme / animu / arepa / caco / komica / vg / vichan / zoo ][ watchlist ]