GitHub link to my scrips here: https://github.com/PhysioFred/PowerShell-Scripts
If you’re a Linux user diving into PowerShell for Active Directory (AD) management, you’ll be pleased to know PowerShell supports many Linux-like aliases. This makes it easier to transition from the Linux command line to PowerShell.
Common PowerShell Aliases for Linux Users
Linux Command | PowerShell Alias | Description |
---|---|---|
ls | ls or Get-ChildItem | Lists files and directories |
cat | cat or Get-Content | Displays file contents |
cd | cd or Set-Location | Changes directory |
cp | cp or Copy-Item | Copies files and directories |
mv | mv or Move-Item | Moves or renames files |
rm | rm or Remove-Item | Removes files and directories |
echo | echo or Write-Output | Prints text to the console |
Quick Exercises to Get Comfortable with PowerShell
I use these exercise as these are common practice accross all scripting and programming langauges.
Exercise 1: Basic Variable Creation
- Create string variables
$userFirstName
and$userLastName
, and concatenate them to form$userFullName
. - Convert
$userFullName
to uppercase and print it.
Exercise 2: Working with Numbers
- Define numeric variables
$userAge
and calculate$yearsToRetirement
based on a retirement age of 65. - Increment
$userAge
and decrement$yearsToRetirement
to simulate a passing year.
Exercise 3: Arrays and Manipulation
- Create an array
$usernames
with values like “jdoe”, “asmith”, “bwayne”. - Print each username, add “tstark” to the array, remove “asmith”, and print the updated array.
Exercise 4: Using Loops in PowerShell
- Create a ForEach loop to iterate through the
$usernames
array. - For each username, print a message saying, “Processing user: [username].”
Why These Exercises?
I use Active Directory in my job so I want to learn to use it without having to use the GUI all the time so I can eventually write scripts and automate.