~2 min read • Updated Dec 21, 2025
1. Understanding Commands
- Internal Cmdlets: Built-in commands written in .NET languages.
- Functions: Script-based commands written in PowerShell.
- WMI Cmdlets: Dynamically generated from WMI classes.
- External Commands: Legacy executables like ping.exe.
Cmdlets use a strict Verb-Noun convention, e.g., Get-Service, New-ADUser, Set-Service.
2. Aliases
Aliases are shortcuts for command names, such as dir or ls for Get-ChildItem. Use them interactively but avoid in scripts for clarity and portability.
3. Parameters
Parameters define command behavior. They follow the format -Name Value. Example:
New-ADUser -Name "JohnDoe" -GivenName "John" -Surname "Doe" -Description "New Employee"
Features:
- String values with spaces require quotes.
- Tab completion helps identify parameters.
- Use full names in scripts for readability.
4. Line Continuation
Long commands can span multiple lines. Example:
Get-Service -Name B*, A*, C* |
Where-Object { $_.Status -eq 'Running' } |
Sort-Object Status
5. Parenthetical Commands
Parentheses evaluate inner commands first. Example:
Get-Process -ComputerName (Get-Content names.txt)
6. Script Blocks
Script blocks group commands with {}. Example:
$sb = {
Get-WmiObject -Class Win32_OperatingSystem
Get-WmiObject -Class Win32_ComputerSystem
}
& $sb
Script blocks are used in remoting and workflows.
Conclusion
PowerShell Syntax provides a structured foundation for scripting and administration. By mastering commands, parameters, aliases, line continuation, parenthetical expressions, and script blocks, administrators can achieve efficient automation and system management.
Written & researched by Dr. Shahin Siami