So far we have learned how to call cmdlets from the console, run scripts at the IDE, and call scripts in two modes. In this very short recipe, we shall learn how to call a PowerShell cmdlet from outside of PowerShell.
Calling a PowerShell cmdlet from outside of PowerShell
How to do it...
- Open a Terminal window.
- At the prompt, type the following:
$ pwsh -h
- Read the syntax for the command.
- At the prompt, type the following:
$ pwsh -c Get-ChildItem
- Let us now run the hello-world.ps1 script:
$ pwsh -f ./Documents/code/github/powershell/chapter-3/hello-world.ps1