Windows Security Fundamentals and PowerShell
Build a working model of Windows identities, permissions, services, and defences, then audit a lab host with read-only PowerShell.
By the end, you’ll be able to…
- Distinguish local accounts from domain accounts and explain how SIDs and groups drive access.
- Read NTFS permissions, inheritance, and effective access without guessing.
- Explain UAC, service accounts, registry autoruns, Windows Firewall, Defender, and BitLocker in practical terms.
- Collect and interpret Windows event log evidence for common security questions.
- Use read-only PowerShell commands to produce a reproducible baseline of a lab machine.
01Accounts, Groups, and the Least-Privilege Habit
Every Windows security decision starts with an identity. A user account, a computer account, and a service account are all security principals, and each one carries a security identifier (SID) that Windows uses in access checks. Local accounts live in the Security Account Manager (SAM) database on a single machine. Domain accounts live in Active Directory and can be used across every computer that trusts the domain. The built-in Administrator account and the SYSTEM account are powerful local identities, and both deserve careful handling.
Groups turn individual permissions into manageable policy. A local group grants rights on one computer. A domain group can be a member of local groups on many computers, which is how organisations avoid assigning permissions person by person. Group scope matters: global groups usually hold users, domain local groups hold permissions, and universal groups can span domains. Nesting groups is convenient but hides effective access, so document the chain and review it regularly.
Least privilege is the discipline of giving an identity only the access it needs, only while it needs it. In practice that means a standard user account for email and browsing, a separate administrative account for server work, and a separate Tier 0 account for directory and domain controller administration. Reusing a Domain Admin account to check email turns a phishing click into a forest-wide compromise. Admin tiers are not bureaucracy; they are a containment strategy.
02NTFS Permissions, Inheritance, and UAC
NTFS permissions control access to files and folders. Each object has a discretionary access control list (DACL) made of access control entries that allow or deny actions for a trustee. Basic permissions such as Read, Modify, and Full Control map to finer-grained advanced permissions. Inheritance lets a child folder receive entries from its parent. When inheritance is disabled, the child keeps a copy of inherited entries as explicit entries, which is a common source of drift and unexpected access.
Effective access combines NTFS permissions with share permissions and group membership. Share permissions apply only over the network, and when share and NTFS permissions differ, the more restrictive result wins. Common mistakes include granting Everyone Full Control, giving Modify on the root of a data drive, leaving orphaned SIDs after staff leave, and letting a service account write to its own program directory. Get-Acl and icacls show the story; compare inherited and explicit entries before changing anything.
User Account Control (UAC) gives administrators a filtered token during normal work and asks for approval before elevation. It reduces accidental system-wide changes and makes privilege use visible. UAC is not a defence against a determined administrator or malware that already runs as an administrator, but disabling it removes a useful speed bump and breaks the expected security model. Keep it enabled, require consent or credentials, and use separate accounts for administration rather than elevating a daily-use account.
03Services, Scheduled Tasks, and the Registry
Services are long-running programs that often start before anyone logs in. Their power depends on the account they run as: SYSTEM and LocalSystem have extensive local rights, NetworkService and LocalService have less, and a dedicated service account may have domain access. Weak service permissions are a classic privilege-escalation path: if a standard user can modify a service binary, its configuration, or its parent directory, they may be able to run code as the service account. Get-Service shows state; sc qc and the Win32_Service class show the binary path and start name.
The registry is the hierarchical configuration database for Windows. Security-relevant locations include Run and RunOnce keys, services, Winlogon, image-file execution options, and policy settings. Attackers use these locations for persistence, and administrators use them for configuration. Query them read-only with reg query, compare the result against a baseline, and be careful not to paste sensitive values into reports. A registry change is not automatically malicious, but an unexpected autorun entry on a server deserves investigation.
Scheduled tasks blend persistence, automation, and privilege. A task can run as SYSTEM, at logon, or on a schedule, and its action can be a script or binary. Review tasks that run with high privilege, point to user-writable paths, or were created outside a change window. schtasks /query provides a readable inventory; export it before and after a change so you can explain exactly what differs.
04Firewall, Defender, BitLocker, and Patch State
Windows Firewall applies separate profiles for domain, private, and public networks. Inbound traffic is blocked by default in a healthy configuration, and rules should be specific about program, port, protocol, and scope. A common mistake is enabling a broad allow rule for troubleshooting and never removing it. Get-NetFirewallProfile gives the profile state; Get-NetFirewallRule lists individual rules. On servers, document every inbound exception and tie it to an application owner.
Microsoft Defender provides antivirus, real-time protection, cloud-delivered protection, attack surface reduction rules, and controlled folder access. Signature age and real-time status are basic health checks, but configuration matters just as much. Attackers add folder or process exclusions to hide payloads, so review exclusions and alert on changes. Get-MpComputerStatus reports health; Get-MpPreference exposes exclusions and policy. A disabled or stale antivirus agent is a finding even when the server is fully patched.
BitLocker encrypts volumes and protects data at rest, especially on laptops that leave the building. TPM-backed startup validates early boot components, and recovery keys must be escrowed somewhere the organisation can retrieve them without giving every helpdesk agent permanent access. Encryption does not protect a running, unlocked session or a server whose disks are already mounted. Pair BitLocker with screen locks, patching, and a tested recovery process rather than treating it as a complete data-protection strategy.
05Event Logs and PowerShell as an Audit Tool
Windows records activity in event logs, but only what audit policy asks it to record. The Security log holds logons, privilege use, account changes, and object access when auditing is enabled. System and Application logs capture service and application events. PowerShell logs, Sysmon, and Defender add detection depth. Important identifiers include 4624 for a successful logon, 4625 for a failure, 4688 for process creation, 4720 for a new user, and 7045 for a new service.
PowerShell is the most practical audit interface on Windows. The commands in this lesson are read-only and safe on a lab machine you control. Run them in an elevated session, record the hostname, date, command, and raw output, and avoid dumping secrets such as passwords or recovery keys into shared notes. A finding is only useful if another person can reproduce it, so keep the exact command alongside the evidence.
Start with an inventory rather than a verdict. Who can log in? Which accounts are enabled? Which services run as SYSTEM? Is the firewall on? Is Defender healthy? Are there unexpected autoruns? Do the answers match the intended build? The gap between the observed state and the documented baseline is your first finding. The code block gives a compact baseline you can adapt to your own lab.
# Read-only baseline. Run PowerShell as Administrator on a lab VM you own.whoami /allGet-LocalUser | Select-Object Name, Enabled, LastLogon, PasswordRequiredGet-LocalGroupMember -Group "Administrators"net usernet localgroup AdministratorsGet-Service | Where-Object Status -eq "Running" | Sort-Object NameGet-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundActionGet-MpComputerStatus | Select-Object AntivirusEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdatedGet-Acl "C:\LabData" | Format-Listicacls "C:\LabData"reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"schtasks /query /fo LIST /vGet-WinEvent -LogName Security -MaxEvents 20 | Select-Object TimeCreated, Id, ProviderName, MessageUSER INFORMATION User Name LAB\student Group Name LAB\Domain Users Group Name LAB\Helpdesk Administrators members: 3 Running services: 84 Domain firewall: True Private: True Public: True Defender real-time protection: True Security events returned: 20
The ideas worth keeping.
- Windows access is built from SIDs, tokens, groups, and ACLs, not from display names.
- NTFS inheritance and share permissions interact; verify effective access rather than assuming one layer controls it.
- UAC, Windows Firewall, Defender, BitLocker, and patching are baseline controls that must be checked, not just enabled once.
- Read-only PowerShell commands produce reproducible evidence for a host baseline.
Make it yours.
Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.
Exercise 1: Audit local administrators
On a lab Windows VM, audit local privileged access with whoami /all, net localgroup Administrators, and Get-LocalGroupMember -Group 'Administrators'. Record every member, whether it is a user or a group, and where it comes from. Then explain two risks and one concrete fix.
Explore a worked solution
Run the three commands in an elevated PowerShell window and save the output with the date and hostname. Build a table with columns for name, object class, source (local or domain), and reason for access. Typical risks: a domain group such as Domain Admins is nested into the local Administrators group, so every domain administrator controls the machine; or a former employee's local account remains enabled. A concrete fix is to remove unnecessary members, use a dedicated local admin account managed by LAPS, and require a documented request for any new local administrator. Re-run the commands and compare the before and after output.Local administrator membership is a small, high-value inventory. It shows who can bypass application controls, install drivers, and read protected files on that host.
Exercise 2: Repair inherited folder permissions
A lab folder at C:\LabData inherited Everyone Modify from its parent. Staff need read-only access to most files, and the Finance group needs Modify on the Finance subfolder. Write commands to inspect the current ACL and correct it, then explain how you would verify the result.
Explore a worked solution
Inspect with icacls "C:\LabData" and Get-Acl "C:\LabData". Remove the broad inherited grant, then grant explicit permissions: icacls "C:\LabData" /remove:g Everyone; icacls "C:\LabData" /inheritance:r; icacls "C:\LabData" /grant:r "LAB\Domain Users:(OI)(CI)(RX)"; icacls "C:\LabData" /grant:r "LAB\Finance:(OI)(CI)(M)". Verify with icacls "C:\LabData" and by testing access as a standard user and as a Finance member. Also confirm the network share permissions are not broader than the NTFS permissions, because the more restrictive result wins.Inheritance is convenient but can spread an overly broad grant across an entire tree. Change the root deliberately, then verify both NTFS and share permissions from the user's perspective.
What stayed with you?
Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.
Keep exploring.
The official references behind this lesson, when you want a second angle or the full details.
One lesson closer.
Reading is a start. Trying it yourself makes the connection.