0
0
PowerShellscripting~30 mins

Why AD management is essential for sysadmins in PowerShell - See It in Action

Choose your learning style9 modes available
Why AD management is essential for sysadmins
📖 Scenario: Imagine you are a system administrator managing a company's network. Active Directory (AD) helps you organize users, computers, and resources securely and efficiently.
🎯 Goal: You will create a simple PowerShell script that shows how AD management helps sysadmins by listing users and checking their account status.
📋 What You'll Learn
Create a list of user accounts with their status
Set a threshold for inactive accounts
Filter users who have been inactive longer than the threshold
Print the filtered list of inactive users
💡 Why This Matters
🌍 Real World
System administrators use Active Directory management to keep networks secure by monitoring user activity and disabling inactive accounts.
💼 Career
Knowing how to script AD user management tasks saves time and reduces errors in daily sysadmin work.
Progress0 / 4 steps
1
Create the user accounts list
Create a variable called users that holds a list of hashtables. Each hashtable should have Name and LastLogonDays keys with these exact entries: @{Name='Alice'; LastLogonDays=10}, @{Name='Bob'; LastLogonDays=45}, @{Name='Charlie'; LastLogonDays=5}, @{Name='Diana'; LastLogonDays=60}.
PowerShell
Need a hint?

Use an array of hashtables to store user names and their last logon days.

2
Set the inactivity threshold
Create a variable called inactiveThreshold and set it to 30 to represent days of inactivity.
PowerShell
Need a hint?

Use a simple variable to hold the number 30.

3
Filter inactive users
Create a variable called inactiveUsers that uses Where-Object to filter users where LastLogonDays is greater than inactiveThreshold.
PowerShell
Need a hint?

Use Where-Object with a script block comparing LastLogonDays to inactiveThreshold.

4
Display inactive users
Use Write-Output to print the Name of each user in inactiveUsers.
PowerShell
Need a hint?

Use a foreach loop to print each inactive user's name.