PowerShell
PowerShell is an automation and configuration management platform consisting of a cross-platform command-line shell and associated scripting language.
Description
PowerShell provides a powerful environment for task automation and configuration management across platforms. It includes the pwsh command-line shell for executing scripts, commands, and interactive sessions. On Kali Linux, it is packaged for easy installation and use in cybersecurity tasks.
Common use cases include running PowerShell scripts for system administration, testing, and exploitation scenarios such as antivirus evasion or reflective loading. The tool supports various execution modes, from one-off commands to full interactive sessions, with options for login shells on Linux/macOS.
It integrates with .NET and offers extensive scripting capabilities, making it suitable for complex workflows in penetration testing and post-exploitation.
How It Works
PowerShell operates as a .NET-based runtime executing scripts and commands in a structured session. The pwsh binary launches the shell, parsing parameters to control execution context like input/output formats (Text/XML), threading (STA/MTA), profiles, and policies. Commands run in local scope when dot-sourced via -File, or as deserialized objects/strings via -Command. Base64-encoded commands via -EncodedCommand handle complex quoting. Exit codes reflect command success ($? true=0, false=1) or script termination.
Installation
sudo apt install powershellFlags
Examples
pwsh -hpwsh -File -.\Get-Script.ps1 -Allpwsh -File .\test.ps1 -TestParam %windir%pwsh -Command {Get-WinEvent -LogName security}pwsh -Command "& {Get-WinEvent -LogName security}"@' "in" "hi" | % { "$_ there" } "out" '@ | pwsh -NoProfile -Command -pwsh -CommandWithArgs '$args | % { "arg: $_" }' arg1 arg2pwsh -NoExit -Command Get-Datepwsh -o XML -c Get-Datepwsh -Login -NoProfile