Hey [correlate], sure thing—I'll walk you through how to enforce this via Group Policy in a Windows enterprise environment (assuming you're on a domain-joined setup with admin access to a domain controller). This focuses on preventing the enabling of optional features like Hyper-V by restricting access to the tools that allow it, such as the "Turn Windows features on or off" dialog and related commands. Keep in mind, this is best for managed environments and requires testing to avoid breaking legitimate workflows. If you're not in IT/admin, consult with your sysadmin first, as misconfiguring GPOs can lock you out.
I'll outline the steps for Group Policy Editor (gpedit.msc on a domain controller or via Group Policy Management Console). This isn't exhaustive—MDM solutions like Intune have similar capabilities, but GPO is a solid starting point.
### Step 1: Open Group Policy Management
- Log in to your domain controller or a machine with the Group Policy Management tools installed.
- Search for and open
gpedit.msc (for local policy) or use the Group Policy Management Console (GPMC) for domain-wide policies.
- Create or edit a GPO that applies to the target computers/users (e.g., link it to an OU with your endpoints).
### Step 2: Restrict the "Turn Windows Features On or Off" Tool
This blocks the GUI way of enabling features:
- Navigate to
Computer Configuration > Policies > Administrative Templates > System.
- Find and enable the policy:
Don't run specified Windows applications.
- In the policy settings, add
optionalfeatures.exe to the list of disallowed applications.
- This prevents users from launching the Windows Features dialog, even with admin rights.
### Step 3: Restrict PowerShell and DISM Commands (for Command-Line Enabling)
Attackers often use PowerShell (e.g., Enable-WindowsOptionalFeature) or DISM to enable features, so lock those down:
- For PowerShell execution: Go to
Computer Configuration > Policies > Administrative Templates > Windows Components > Windows PowerShell.
- Enable
Turn on PowerShell Script Block Logging for monitoring (not blocking, but useful for detection).
- To restrict execution, consider AppLocker (under
Computer Configuration > Policies > Windows Settings > Security Settings > Application Control Policies > AppLocker):
- Create a new Executable Rule to deny PowerShell.exe (or pwsh.exe) for non-admin users, or whitelist only approved scripts.
- For DISM: Use Software Restriction Policies (SRP) under
Computer Configuration > Policies > Windows Settings > Security Settings > Software Restriction Policies.
- Create a new policy if none exists.
- Add a rule to disallow
dism.exe in %SystemRoot%\system32 (set it to "Disallowed" for paths or hashes).
### Step 4: Specifically Target Hyper-V (Optional but Direct)
- To prevent Hyper-V installation outright: Under
Computer Configuration > Policies > Administrative Templates > System > Device Installation > Device Installation Restrictions, you can restrict hardware IDs, but for features like Hyper-V, it's more about the above restrictions.
- Alternatively, use a script or GPO to monitor and revert changes: Enable auditing for feature installations via
Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Object Access > Audit Other Object Access Events.
### Step 5: Apply and Test
- Link the GPO to the appropriate OU, enforce it, and run
gpupdate /force on target machines.
- Test thoroughly: Try enabling Hyper-V legitimately (it should fail), and ensure it doesn't block other needed features.
- Monitor logs: Check Event Viewer (Windows Logs > System) for denied attempts, which could indicate foul play.
This setup raises the bar for attackers—they'd need to bypass GPO enforcement, which often requires domain admin creds (another layer to secure). For cloud-based MDM like Intune, you'd set up similar restrictions via Configuration Profiles > Administrative Templates.
If you're dealing with a home setup or non-domain environment, local policy (gpedit.msc) can do a lighter version, but it's less robust. Got a specific environment in mind (e.g., AD domain vs. standalone)? Or need details on Intune? Let's geek out on this!
