Diff: PowerShell
Comparing revision #1 (2024-03-02 21:49:51) with revision #2 (2026-06-22 11:42:32).
| Old | New |
|---|---|
'''PowerShell''' is a task automation and configuration management framework from [[Microsoft]], consisting of a command-line shell and scripting language built on the .NET Framework. It is designed primarily for system administrators and power users to manage systems. PowerShell's scripting language is built on the .NET Framework and is designed to be a high-level language for administrators and developers alike. It can also be used as a scripting language for embedded systems. |
|
== Key Features == |
|
'''PowerShell''' is a command-line shell, scripting language and automation framework from Microsoft. It is used for system administration, cloud management, deployment work, diagnostics and repeatable automation. |
|
* Scripting Language: PowerShell is a full-featured scripting language that allows users to create scripts to automate tasks. Scripts are saved in files with a .ps1 extension and can be executed from the command line or from within the PowerShell environment. |
|
* Extensibility: PowerShell is extensible, allowing users to create their own commands, called cmdlets, and to add functionality through the use of modules. These modules can be created by Microsoft or by third-party developers. |
|
* Pipeline: PowerShell supports a powerful pipeline mechanism that allows the output of one command to be used as the input for another command. This allows for the creation of complex commands by stringing together multiple simpler commands. |
|
* Integration with .NET: PowerShell is built on the .NET Framework and allows for seamless integration with .NET libraries. This allows users to use .NET objects and methods directly in their PowerShell scripts. |
|
* Remote Management: PowerShell supports remote management of Windows-based systems, allowing users to run PowerShell commands on remote systems and retrieve the results. |
|
Modern PowerShell is cross-platform and runs on Windows, Linux and macOS. It is separate from the older Windows PowerShell 5.1 line that ships with many Windows systems. |
|
== Getting Started == |
|
To get started with PowerShell, users can open a PowerShell prompt by typing <code>powershell</code> in the Windows search bar and pressing Enter. This will open the PowerShell command-line interface, where users can type commands and execute scripts. |
|
== Design == |
|
PowerShell is built around commands called cmdlets. Cmdlets usually follow a verb-noun naming pattern, such as Get-Process or Set-Location. Commands can be combined through a pipeline, where structured objects pass from one command to the next. |
|
PowerShell supports a wide range of commands, including those for managing files and directories, working with the Windows registry, and managing Windows services and processes. |
|
This object pipeline is one of the main differences between PowerShell and text-focused shells. Instead of only passing plain text, PowerShell can pass .NET objects with named properties and methods. |
|
To see a list of available cmdlets, users can type <code>Get-Command</code> at the PowerShell prompt. This will display a list of all available cmdlets, along with a brief description of each. |
|
== Uses == |
|
Common uses include file and service management, Windows administration, Azure and Microsoft 365 administration, build and deployment scripts, log collection, scheduled tasks, remote sessions and repeatable troubleshooting. |
|
== Basic Syntax == |
|
PowerShell commands are composed of cmdlets and parameters. Cmdlets are the basic building blocks of PowerShell commands and are similar to commands in other shells, such as Bash or PowerShell. Parameters are used to modify the behaviour of cmdlets. |
|
PowerShell modules extend the shell with extra commands. Microsoft and third parties publish modules for Windows features, cloud services, development tools and administration tasks. |
|
Cmdlets in PowerShell follow the Verb-Noun convention, with the verb indicating the action to be performed and the noun indicating the object on which the action is to be performed. For example, the cmdlet <code>Get-Process</code> is used to retrieve information about running processes on a computer. |
|
== Scripting == |
|
PowerShell scripts usually use the .ps1 file extension. Scripts can define functions, accept parameters, call modules, handle errors and work with objects returned by commands. |
|
== Example Commands == |
|
Execution policy is a safety feature that controls whether scripts can run in some Windows contexts. It is not a full security boundary, but it helps reduce accidental script execution. |
|
* <code>Get-Process</code>: This cmdlet is used to retrieve information about running processes on a computer. For example, <code>Get-Process -Name notepad</code> will return information about the Notepad process. |
|
* <code>Get-Service</code>: This cmdlet is used to retrieve information about the services running on a computer. For example, <code>Get-Service -Name Spooler</code> will return information about the Print Spooler service. |
|
* <code>Get-EventLog</code>: This cmdlet is used to retrieve information from the event logs on a computer. For example, <code>Get-EventLog -LogName System</code> will return the System event log. |
|
* <code>Get-ChildItem</code>: This cmdlet is used to retrieve information about the files and directories on a computer. For example, <code>Get-ChildItem -Path C:\</code> will return the contents of the C:\ directory. |
|
== Versions == |
|
Windows PowerShell is based on the .NET Framework and is Windows-only. PowerShell 7 and later are based on modern .NET and are cross-platform. Some older modules still depend on Windows PowerShell, while newer modules usually target PowerShell 7 where possible. |
|
== Extending PowerShell == |
|
In addition to the built-in cmdlets, PowerShell can be extended with third-party cmdlets and modules. These extensions can add functionality to PowerShell, such as managing Active Directory objects or managing SQL Server databases. |
|
== See Also == |
|
* [[Microsoft]] |
|
* [[Microsoft_Windows]] |
|
* [[Cloud_Computing]] |
|
* [[Windows_7]] |
|
== PowerShell ISE == |
|
PowerShell ISE (Integrated Scripting Environment) is an integrated development environment (IDE) for PowerShell scripting. It provides features such as syntax highlighting, code completion, and debugging tools to make writing and debugging PowerShell scripts easier. |
|
== References == |
|
* [https://learn.microsoft.com/en-us/powershell/scripting/overview Microsoft Learn: What is PowerShell?] |
|
* [https://learn.microsoft.com/en-us/powershell/ Microsoft Learn: PowerShell documentation] |
|
* [https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell Microsoft Learn: Installing PowerShell] |
|
* [https://github.com/PowerShell/PowerShell GitHub: PowerShell] |
|
== Getting Help == |
|
Users can get help with PowerShell commands by using the <code>Get-Help</code> cmdlet. For example, <code>Get-Help Get-Process</code> will display help information for the <code>Get-Process</code> cmdlet. Users can also use the <code>Update-Help</code> cmdlet to download and install the latest help files for PowerShell. |
|
[[Category:Software]] |
|
[[Category:Programming]] |