[ prog / sol / mona ]

prog


What shell do you use?

53 2024-10-14 08:13

PowerShell is kind of interesting. I'm still very new,. Are you interested in trying it: https://books.goalkicker.com/PowerShellBook/

# help system
Update-Help -ErrorAction Continue
help Get-Process   # alias for Get-Help foobar | more
Get-Help -examples Out-GridView
Get-Process | Get-Member  # pipe object, not text
Get-Command *json*  # which commands contain "json"?
Get-alias select
Get-Verb
Show-Command Get-Process  # open a GUI for command

# List processes without active windows.
# it's formatted in a GUI table thing.
# You could also use Format-Table or Format-List
#
# let's checks if mainWindowTitle property for each process is $null and select those objects:
Get-Process | Where-Object -EQ -value $null  {$_.mainWindowTitle} | Out-GridView

# who is using up teh RAM?
Get-Process | Sort-Object -Property WS | Select-Object -Last 5

# calculate file checksum
Get-FileHash gentoo.iso

# find new files added in the last 7 days
Get-ChildItem -Path Downloads -Recurse | Where-Object CreationTime -gt (Get-Date).AddDays(-7)

# find large files, convert size to MB with 2 decimal places, sort by the new "Size (MB)" property and format as table
Get-ChildItem -Path Downloads -Recurse | Where-Object { $_.Length -gt 255MB } | Select-Object FullName, @{Name="Size (MB)"; Expression={ [math]::Round(($_.Length / 1MB), 2) }} | Sort-Object -Property "Size (MB)" | Format-Table
56


VIP:

do not edit these