Powershell Basics
Overview:
The following goes over Powershell and the basics
What is PowerShell?
PowerShell is a powerful task automation and configuration management framework from Microsoft. It includes a command-line shell and scripting language, designed to help professionals control and automate the administration of Windows and applications.
Key Features:
Cmdlets: Lightweight commands within PowerShell.
Pipelines: Pass outputs from one cmdlet as inputs to another.
Scripting Language: Create scripts to automate tasks.
Automation: Simplify complex and repetitive tasks.
Object-Oriented: Operates with objects, not just text.
Installing and Updating PowerShell
For Windows Users:
Check for Pre-Installed PowerShell:
Most Windows versions come with Windows PowerShell pre-installed.
Open PowerShell: Search for "PowerShell" in the Start menu and launch it.
Install PowerShell Core:
Download the latest version from the PowerShell GitHub releases page.
Follow the installation prompts.
For macOS and Linux Users:
Download and Install:
Visit the PowerShell GitHub page.
Follow platform-specific installation instructions provided.
Updating PowerShell:
Download and run the latest installer from the PowerShell GitHub releases page to update.
Basic Command Syntax and Structure
PowerShell commands, or cmdlets, use a Verb-Noun naming convention:
Examples:
Common Verbs:
Get
: Retrieve dataSet
: Change dataNew
: Create a new resourceRemove
: Delete a resourceStart
: Begin an operation
Practical Examples to Get Started
Exercise 1: Open PowerShell
Windows: Search for "PowerShell" in the Start menu and open it.
macOS/Linux: Open your terminal and type
pwsh
to start PowerShell Core.
Exercise 2: Run Basic Commands
List all running processes:
Get help for a cmdlet:
Retrieve the current date and time:
Exercise 3: Explore PowerShell Help
Update the help system:
Get detailed help for a cmdlet:
Exercise 4: Check Parameters of a Given Command
Last updated