powershell
Run PowerShell commands and scripts
TLDR
View the documentation for the command referring to the latest, cross-platform version of PowerShell (version 6 and above)
View the documentation for the command referring to the legacy Windows PowerShell (version 5.1 and below)
SYNOPSIS
pwsh [options] [-File <filePath>] [arguments]
PARAMETERS
-File <filePath>
Executes the specified script file. Equivalent to piping the script content to the shell.
-Command <script>
Executes the specified command (scriptlet). Can be used for inline scripting.
-EncodedCommand <base64EncodedCommand>
Executes a Base64 encoded command string.
-ConfigurationName <string>
Specifies the configuration name for a remote endpoint (used with remoting).
-NoProfile
Suppresses loading of the PowerShell profile.
-NonInteractive
Runs PowerShell in a non-interactive mode (suitable for background processes).
-ExecutionPolicy <policy>
Sets the execution policy for the session (e.g., RemoteSigned, Unrestricted).
-Help
Displays help information about PowerShell.
-Version
Displays the PowerShell version.
DESCRIPTION
PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and associated scripting language. Initially built for Windows, it has been ported to Linux and macOS, allowing users to manage systems across different operating systems using a consistent syntax and object-based paradigm.
PowerShell utilizes cmdlets (command-lets), which are lightweight commands designed for specific tasks. These cmdlets operate on objects, rather than plain text streams, enabling more structured data processing and manipulation. This object-oriented approach distinguishes it from traditional shell scripting environments.
On Linux, the powershell command invokes the PowerShell interpreter, allowing users to execute scripts, run cmdlets, and interact with the shell. It enables administrators and developers to automate tasks, manage configurations, and perform system administration operations, similar to how it is used on Windows. It also supports connecting to remote servers via SSH, and can be used to automate the management of remote machines.
PowerShell provides access to the .NET Common Language Runtime (CLR), allowing interaction with .NET libraries and objects, greatly expanding its capabilities. Its ability to process structured data and interact with various systems makes it a powerful tool for cross-platform system administration.
CAVEATS
PowerShell on Linux may not have all the cmdlets and modules available on Windows. Module compatibility can vary. Case-sensitivity is important in Linux environments unlike Windows.
<B>PROFILES</B>
PowerShell supports profiles, which are scripts that run when PowerShell starts. These profiles allow you to customize your PowerShell environment by setting aliases, functions, and other settings. The location of the profile file varies depending on the platform.
<B>MODULES</B>
PowerShell uses modules to extend its functionality. Modules contain cmdlets, providers, functions, and other resources that can be used to automate tasks and manage systems. You can install modules from the PowerShell Gallery or create your own modules.
HISTORY
PowerShell was originally developed by Microsoft as a task automation and configuration management framework for Windows. It was initially released as Windows PowerShell in 2006. It was later open-sourced and ported to Linux and macOS as PowerShell Core, and now it's known as simply PowerShell. This cross-platform version aims to provide a consistent scripting and automation experience across different operating systems. The name of the executable in Linux is 'pwsh'.