1/41
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
shell
is a user interface for accessing the operating system's services. It interprets and executes commands entered by the user.
Two types of shell:
- Command-line Shell (e.g., CMD, Bash)
- Graphical Shell (e.g., Windows Explorer)
PowerShell
- A modern command-line shell. Built on the .NET Framework. Accepts and returns .NET objects. Designed for task automation.
- Get-Service | Where-Object {$_.Status -eq "Running"}
Key PowerShell Features
- Command-line history & tab completion.
- In-console help.
- Pipeline for chaining commands.
- Alias and object support.
PowerShell vs. Command Prompt
- PowerShell: Object-based.
- CMD: Text-based.
- PowerShell supports scripting and automation.
PowerShell Architecture
- Based on .NET CLR.
- Works with .NET objects.
- Extensible via modules and classes.
Launching PowerShell
- Start Menu → Windows PowerShell.
- Use Run or CMD: PowerShell or PowerShell ISE.
PowerShell Console
For direct command input.
Powershell ISE
For writing, testing, and debugging scripts
Arrow Keys
Navigate History
F7
Shows History list
Tab
Auto-complete commands
Cmdlets Overview
- PowerShell commands = Cmdlets.
- Use Verb-Noun format (e.g., Get-Process).
- View all: Get-Command.
- Get-Command -Verb Get
Get-Help
shows command info.
Use -Examples to see usage.
- Example:
- Get-Help Get-Service -Examples.
- Get-Help Get-SystemDriver -Examples
Get-Process
View running processes.
Get-Service
View services.
Get-Location
Show current directory.
Aliases
shorthand for cmdlets.
Example:
- New-Alias listDir Get-ChildItem
Get-Alias
View all aliases.
New-Alias
Hist Get-History
- Example:
•New-Alias listDir Get-ChildItem
-WhatIf
Preview results.
Confirm
Ask before executing.
-Verbose, -Debug
Detailed output.
Cmdlet Parameters
Example:
- Stop-Process -Name notepad -WhatIf
Working with Objects
- Cmdlets return objects.
- Use Get-Member to explore properties/methods.
- Example: Get-Service | Get-Member.
Output Formatting
Format-Table, Format-List, Format-Wide.
- Example: Get-ChildItem | Format-Table -AutoSize.
Exporting Data
- ConvertTo-Html: Create HTML output.
- Export-CSV: Save to .csv file.
- Invoke-Item: Open exported file.
- Example:
- Get-Process | Export-Csv -Path C:\Processes.csv
•
ConvertTo-Html
Create HTML output.
Export-CSV
Save to .csv file.
Invoke-Item
Open exported file.
PowerShell Providers
Access data like file system or registry.
Get-PSProvider
Lists Providers
Get-PSDrive
View Drives
Certificate Provider
- Use Set-Location cert:: to browse certificates.
- Export using Export-CSV.
- Example:
- Get-ChildItem cert:: | Export-Csv C:\certs.csv
•
PowerShell Scripting Basics
- Supports variables, arrays, hashtables.
- Use operators, loops, conditions, functions.
Variable Types
- [int], [string], [bool], [xml], etc.
- $x = 5, $name = 'PowerShell'.
$_
Current pipeline object.
$Args
Arguments to function.
$PsHome
PowerShell install path.
Conditional Logic
- Use if, elseif, else for decision making.
- Switch: Handle multiple cases.
- Example:
- if ($x -eq 5) { Write-Host "Five" }
Writing Functions
- Function Greet { Write-Host 'Hello' }
- Use $args to pass input values.
PowerShell Pipeline
- Use | to chain commands.
- Example: Get-Process | Where { $_.Handles -gt 500 } | Sort Handles | Format-Table
- Get-Service | Where-Object {$_.Status -eq "Running"}