PowerShell is a hilariously verbose command environment, both in terms of every damn command and also in terms of what it spits out at you when something is wrong---at least, at the times where it doesn't just refuse to say anything at all. Unhelpfully verbose or unhelpfully taciturn seem to be its only two modes! However, PowerShell is necessary in many scenarios thanks to being more featureful and modern than Windows' vestigial `cmd.exe` environment.
So here are some important things, presuming you already know how to use normal shells on #Linux or such. And if you don't, stop reading this and learn to be comfortable there first; it's a much less user-hostile place to be, far fewer lines of red error text suddenly thrust upon you. Seriously, it's generally far less of a hassle even on Windows to just use the [[ documentation/windows/wsl/ ]]! (You can even pipe to it, ex `dir | wsl grep -i SomeFilenameIAmLookingFor`.)
== Basic Equivalents ==
| Posix-y command | PowerShell equivalent | Documentation | Notes
| --------------------- | -------------------------- | ------- |
| `ls` | `ls` / `dir` / `Get-ChildItem` | [[https://ss64.com/ps/get-childitem.html| ss64]], [[ https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem | Microsoft ]] | Acts like `ls -l`, no easy equiv of just `ls`
| `grep` | `Select-String -Pattern` | [[ https://ss64.com/ps/select-string.html | ss64 ]], [[ https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Select-String | Microsoft ]]|
| `pushd` | `pushd` / `Push-Location` | [[ https://ss64.com/ps/push-location.html | ss64 ]] | Works in DOS too, less annoying than `cd` there in fact since it'll traverse filesystem boundaries |
| `top` | see [[ documentation/windows/powershell#top|below]] | see [[ documentation/windows/powershell#top|below]] | see [[ documentation/windows/powershell#top|below]] |
| `tree` | `tree` | | Looks fine on screen, but attempts to grep or FindStr fill the output with ????s |
=== top ===
You almost just have to grab some equivalent compiled for Windows. The best you can really do is [[ https://superuser.com/questions/176624/linux-top-command-for-windows-powershell | crazy one-liners]] like for example:
```While(1) { $p = get-counter '\Process(*)\% Processor Time'; cls; $p.CounterSamples | sort -des CookedValue | select -f 15 | ft -a}```
== Examples ==
```
lang=powershell
# Get the current state of scheduled tasks with the string "T401" in their name
schtasks | Select-String -Pattern "T401"
# See if anything with "notepad" in the executable name are running
tasklist | Select-String -Pattern "notepad"
```
== External links for other problems ==
* https://stackoverflow.com/questions/53834304/how-do-i-git-clone-from-a-windows-machine-over-ssh
* [[ https://github.com/PowerShell/Win32-OpenSSH/issues/1082 | Remote SSH commands require double escaping before hitting the DefaultShell ]]