How it works...
PowerShell is not an application that runs on top of Bash. PowerShell is a shell itself. However, it can be called from Bash just like another application. Like applications, the pwsh command takes in arguments, which are then processed by PowerShell.
The two main ways we may want to use PowerShell from within Bash is to run a single command or call a script file. You can even call a script block; however, this must be done from within PowerShell. In most cases, running single cmdlets or calling a script should suffice.
In general, when calling pwsh with cmdlets, make -Command (or -c) the last parameter, since anything that comes after the cmdlet itself is considered a cmdlet argument. The same goes for -File as well.
When ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access