There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Kushia ,
@Kushia@lemmy.ml avatar

Microsoft products in this area are weird to me. Like C#, Powershell is great on one hand yet annoying and more difficult to rangle on the other compared to other solutions that are out there.

lud ,

At least it’s more readable than Bash.

Although that’s not much of an accomplishment.

madcaesar ,

Please explain for a dummy.

catsup ,

OP was trying to get the information for a hard disk in their computer, but after running a command it looks like the serial number for that disk is 💙B

icanwatermyplants ,

The humor is in the amount of hoops to jump through to get some basic info out using Powershell. Under Linux one would use a single command or just check what the system exposes in the form of a file.

I have no idea how to do forensics under Windows to be honest. You’d probably have to write something to get to the block layer so it can be dumped and analyzed. Perhaps OP can amuse us how he went about it.

lud , (edited )

It’s just one command with a bunch of selects, you could probably just run the first part. I can try it myself later.

There are a lot of software that forensics can use, I don’t know how common windows is but considering its usage for everything else in companies and governments, I wouldn’t be surprised if forensics use primarily Windows.

SpaceNoodle ,

lsusb

Look what they need to mimic a fraction of our power.

SnotFlickerman ,
@SnotFlickerman@lemmy.blahaj.zone avatar

Text Based OS > Object Based OS

Everything that is wrong with PowerShell in my opinion is driven by the Object Oriented nature of Windows as an OS.

Since everything in Linux is text, grep is king.

SzethFriendOfNimi ,

It would be better if they leaned into it. Instead it is object based…. Until it isn’t because then it’s clunky.

skilltheamps ,

Also lots of command line tools have a flag to output json, and then you can do everything powershell can

polaris64 ,

And for those that don’t you have JC

bleistift2 ,

Don’t you think immediately getting the property you’re interested in from an object is easier and more readable than first grepping some output to get the line you want and then removing the leading and trailing garbage on that line manually?

I thing PS scripting would be much more fun if the words weren’t so annoyingly long.

docAvid ,

first grepping some output to get the line you want and then removing the leading and trailing garbage on that line manually

That’s not what we do, though. Give me a more concrete example, and I’ll let you know how I would expect to do it in a nix environment. I’d be curious to compare. Since I have zero experience with powershell, I am not really sure what to expect. The couple times I’ve glanced at a powershell script it looked awful, but I could be falling into Paul Graham’s blub paradox there. OK, I don’t think so, but maybe.

bleistift2 ,

For instance: Get the temperature of the “Composite” sensor from this output:


<span style="color:#323232;">$ sensors
</span><span style="color:#323232;">k10temp-pci-00c3
</span><span style="color:#323232;">Adapter: PCI adapter
</span><span style="color:#323232;">Tctl:         +37.1°C  
</span><span style="color:#323232;">
</span><span style="color:#323232;">BAT1-acpi-0
</span><span style="color:#323232;">Adapter: ACPI interface
</span><span style="color:#323232;">in0:          16.07 V  
</span><span style="color:#323232;">curr1:         1.80 A  
</span><span style="color:#323232;">
</span><span style="color:#323232;">amdgpu-pci-0500
</span><span style="color:#323232;">Adapter: PCI adapter
</span><span style="color:#323232;">vddgfx:        1.46 V  
</span><span style="color:#323232;">vddnb:       918.00 mV 
</span><span style="color:#323232;">edge:         +35.0°C  
</span><span style="color:#323232;">slowPPT:     1000.00 uW 
</span><span style="color:#323232;">
</span><span style="color:#323232;">nvme-pci-0200
</span><span style="color:#323232;">Adapter: PCI adapter
</span><span style="color:#323232;">Composite:    +28.9°C  (low  =  -5.2°C, high = +79.8°C)
</span><span style="color:#323232;">                       (crit = +84.8°C)
</span><span style="color:#323232;">
</span><span style="color:#323232;">acpitz-acpi-0
</span><span style="color:#323232;">Adapter: ACPI interface
</span><span style="color:#323232;">temp1:        +37.0°C  (crit = +120.0°C)
</span>

Without a cryptic awk incantation that only wizards can understand, that would be:

sensors | grep Composite | grep -Po ‘Composite:.*?C’ | grep -Eo ‘[[:digit:]]{1,2}.[[:digit:]]’

docAvid ,

I think I misunderstood you, when you said “manually”, to mean as a human intervention in the process. What you’re showing here is an extra processing step, but I wouldn’t call that manual. Just want to clear that up, but I’m still down to play.

Instead of three greps, you could use one sed or awk. I don’t think there’s anything particularly wizardly about awk, and it would be a lot less cryptic, to me, than this chain of greps.

But a much better idea would be to use sensors -j to get json output, intended for machine reading, and pass that to jq. Since I don’t have the same sensors output as you, I’m not sure exactly what that would be, but I am guessing probably something like:


<span style="color:#323232;">sensors -j | jq '."nvme-pci-0200".Composite.composite_input'
</span>

I look forward to seeing how you would do this in PS. As I said previously, I don’t know it at all, so I’m not sure what you’re comparing this to.

bleistift2 , (edited )

What you’re showing here is an extra processing step, but I wouldn’t call that manual.

Yes, it’s not manual by the dictionary definition, but it is an extra step. This is another meaning of manual in my particular bubble [Edit: that I didn’t think to specify].

But a much better idea would be to use sensors -j to get json output, intended for machine reading, and pass that to jq.

This is my initial point, exactly. Dealing with objects is way easier than using the ‘default’ line-wise processing. Only Powershell made that the default, while in Linux you need to hope that utilities have an option to toggle it on – and then also have jq installed to process the objects.

I look forward to seeing how you would do this in PS. As I said previously, I don’t know it at all, so I’m not sure what you’re comparing this to.

[Edit, since I forgot to answer your main point:] I don’t program in PS. I don’t like the verbosity. But I do think MS has a point in pushing objects as the prime unit in processing instead of lines.

ruckblack ,

I’ve always been particularly revolted by powershell syntax and utilities

Carighan ,
@Carighan@lemmy.world avatar

It’s from the beginning meant to be fully scripted though. You’re not supposed to be putting in these commands manually, it’s meant to be used in an environment where the 5-50 commands you or your company needs constantly have aliases and script files defined and on PATH.

ruckblack ,

I mean, that’s great, I hate scripting in powershell too though lol.

Carighan ,
@Carighan@lemmy.world avatar

Fair, as do I honestly. 😅

skilltheamps ,

Yes, if it was as object based as it claims, Get-WmiObject would subtract WmiObject from Get. Instead it is like having all the clutchy drawbacks from being object based without reaping any of the potential bemefits.

If you want anything that actually is object based, just use xon.sh - sane and familiar syntax with insane amounts of power just like that

yetAnotherUser ,

Or nushell.

kogasa ,
@kogasa@programming.dev avatar

Is this a joke

OfficerBribe , (edited )

Get-Disk would have sufficed here, no real need to use WMI here. That said, you would still need to filter USB device and select properties you want to retrieve.

And unrelated, but if WMI class needs to be queried, Get-CimInstance is the preferred method instead of Get-WmiObject for quite some time.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines