Language Basics
Learn PowerShell syntax by comparing it to C#.
Variables
// C# - declare and assign
var name = "Michael";
string title = "Developer";
int count = 5;# PowerShell - assign (type is inferred)
$name = "Michael"
$title = "Developer"
$count = 5
# Optionally specify type
[string]$title = "Developer"
[int]$count = 5C# to PowerShell Translation
Arrays
Hashtables
Ordered Dictionaries
Comparison Operators
C#
PowerShell
Description
Logical Operators
C#
PowerShell
Description
Pattern Matching
String Interpolation
Escape Characters
Multi-line Strings
String Operations
For Loop
ForEach Loop
While Loop
Accessing .NET Types
Common .NET Types
Creating .NET Objects
Comments
Functions and Methods
Calling Methods
Defining Functions
Error Handling
Performance Considerations
Better Collections
Suppressing Output
Key Differences Summary
Concept
C#
PowerShell
Next Steps
Last updated