Scripting

Anonymized scripts from the workshop and the day job. Copy, adapt, break, improve.

Powershell466 lines

Find Which Computer a Domain User Last Logged On From

Active Directory stores when a user last logged on, but not where. This script fills that gap by querying the Security event log across every domain controller, correlating Kerberos and NTLM authentication events, and resolving them to a computer name. Run it when a user reports a problem and you need to know what machine they were on, or when you’re chasing down suspicious activity and need a starting point.

Read »
Powershell345 lines

PowerShell: Bulk Add Users to Microsoft Entra Groups

This script adds lists of users to one or more Microsoft Entra ID groups in bulk, using the Microsoft Graph PowerShell SDK. It’s built for license-group provisioning scenarios where you need to drop a batch of UPNs into specific groups and get a clear record of what happened. You’d run this when onboarding a wave of users, rolling out a licensed feature, or cleaning up group membership after an org change.

Read »
Powershell130 lines

PowerShell Login Script: Drive Mapping and Greeting Popup

This script is a modern PowerShell replacement for the classic VBScript logon script. It maps network drives for all users, maps additional drives based on AD group membership, and shows a time-of-day greeting popup at login. Deploy it via GPO under User Configuration > Policies > Windows Settings > Scripts (Logon), PowerShell Scripts tab.

Read »
Powershell24 lines

PowerShell: Create a Distribution List with an Array

This script creates an Exchange Online distribution group and bulk-adds members to it using a PowerShell array and a foreach loop. It’s useful when you need to stand up a new distribution list with a known set of members without clicking through the Exchange admin center one address at a time.

Read »
Text

Managing AD Groups with PowerShell

As a Windows system administrator, managing Active Directory (AD) groups is probably something you do every day. While you could use the Active Directory Users and Computers (ADUC) MMC snap-in, what happens when you need to manage groups across multiple domains or automate group management tasks? That’s where PowerShell comes in handy.

Read »
Bash640 lines

Multi-DC Active Directory Health Check Script

This PowerShell script runs a broad battery of AD health checks against every Domain Controller in your domain, either auto-discovered or passed explicitly. It pulls system info, replication state, dcdiag results, event logs, account hygiene, DNS health, and more from each DC via PSRemoting, then writes per-DC text reports and a side-by-side comparison summary. Run it when you want a fast, consistent snapshot across all DCs without clicking through multiple tools.

Read »
Powershell98 lines

PowerShell Script: Pull Domain Info from Any Domain-Joined PC

This script collects a snapshot of everything domain-related on the local machine: join status, logged-on users, secure channel health, time sync source, AD site, network config, and key AD domain details. Run it when you’re troubleshooting a domain issue and want all the relevant facts in one shot instead of running eight separate commands.

Read »