LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pwsh

Cross-platform PowerShell shell

TLDR

Start PowerShell
$ pwsh
copy
Execute a command
$ pwsh -Command "[Get-Process]"
copy
Run a script file
$ pwsh -File [script.ps1]
copy
Run without loading the profile
$ pwsh -NoProfile -Command "[command]"
copy
Run non-interactively for automation
$ pwsh -NonInteractive -Command "[command]"
copy
Run a base64-encoded command
$ pwsh -EncodedCommand [base64_string]
copy
Start in a specific working directory
$ pwsh -WorkingDirectory [/path/to/dir]
copy
Show version
$ pwsh -Version
copy

SYNOPSIS

pwsh [options] [-File file [args]] [-Command { - | script-block | string }]

DESCRIPTION

pwsh is the executable for PowerShell, Microsoft's cross-platform shell and scripting language that runs on Linux, macOS, and Windows. It provides an object-oriented pipeline where commands output structured .NET objects rather than plain text, enabling rich data manipulation without parsing.PowerShell includes a comprehensive set of cmdlets for system administration, file management, and process control. Scripts use the .ps1 extension and support advanced features like modules, remoting, and error handling. The -Command flag executes inline commands while -File runs script files, and -NonInteractive mode is useful for automation and CI/CD pipelines.

PARAMETERS

-Command | -c CMD

Execute a command string or script block.
-File | -f FILE
Execute a script file. Must be the last parameter.
-NonInteractive | -noni
Disable interactive prompts; useful for automation.
-NoProfile | -nop
Don't load the PowerShell profile.
-NoLogo | -nol
Hide the banner at startup of interactive sessions.
-NoExit | -noe
Don't exit after running startup commands.
-Login | -l
Start as a login shell (Linux/macOS only). Must be first parameter.
-EncodedCommand | -e BASE64
Accept a base64-encoded UTF-16LE command string.
-ExecutionPolicy | -ep POLICY
Set the execution policy for the session (Windows only).
-WorkingDirectory | -wd DIR
Set the initial working directory.
-CommandWithArgs | -cwa CMD [args]
Execute a command with arguments populating $args.
-ConfigurationFile FILE
Specify a session configuration (.pssc) file path.
-OutputFormat | -o {Text | XML}
Format of output. Default is Text.
-InputFormat | -if {Text | XML}
Format of data sent to PowerShell.
-SettingsFile FILE
Override the system-wide powershell.config.json for the session.
-Interactive | -i
Present an interactive prompt. Inverse of -NonInteractive.
-Version | -v
Show version.

CONFIGURATION

~/.config/powershell/profile.ps1

User profile script executed on startup, used to define aliases, functions, and environment customizations.
~/.config/powershell/Microsoft.PowerShell_profile.ps1
Host-specific profile loaded only in the default PowerShell host.
$PROFILE
Built-in variable pointing to the current user's profile path for the active host.

CAVEATS

Requires separate installation on Linux/macOS. Different from Windows PowerShell 5.1 (powershell.exe). All parameters are case-insensitive.

HISTORY

PowerShell Core was released by Microsoft as cross-platform shell.

SEE ALSO

bash(1), zsh(1), sh(1), fish(1)

Copied to clipboard
Kai