Deploying Windows devices in an enterprise environment has evolved significantly, especially with the rise of cloud-first strategies and zero-touch provisioning. Windows Autopilot streamlines device setup, but IT admins still face the challenge of ensuring every device meets organizational standards right from the start. This is where a Windows Desired State Configuration (DSC) package comes in.
By applying DSC packages during Windows Autopilot enrollment, IT admins can baseline deployments, remove unnecessary apps, configure essential settings, and deliver a consistent user experience across all Windows devices.
Note
This post should not be confused with PowerShell Desired State Configuration (DSC) for Windows , although some concepts are similar. This post focuses on creating a desired state for a device using a custom script/package for use in any Windows Autopilot scenario.Windows Desired State Configuration packages
A Windows Desired State Configuration package is a deployment artifact that defines and applies a specific configuration state on Windows devices. Think of it as a blueprint that describes how a device should be configured - what apps should be removed, which features should be enabled or disabled, and what settings should be applied.
Traditionally, device deployment involved manual imaging and post-deployment configuration tasks. Without a standardized approach, devices could end up with unwanted software, inconsistent settings, and varying security postures. This is particularly problematic in Windows Autopilot scenarios where devices come directly from the manufacturer with varying pre-installed software.
A DSC package addresses this by establishing a baseline - a clean starting point that ensures consistency across your device fleet. Unlike policies that enforce configurations users cannot change, a DSC package provides a default state that users may adjust according to their needs.
Benefits of baseline configurations
- Consistency: Every device starts with the same apps and settings
- Efficiency: Automated configuration reduces manual setup time and minimizes errors
- Compliance: Devices align with organizational standards from the start
- Security: Remove unwanted software and apply security hardening out of the box
What can a DSC package configure?
A DSC package can address a wide range of configuration scenarios. The following examples illustrate some common possibilities, though your implementation could include additional configuration artifacts based on organizational requirements:
- App management: Removal of pre-installed apps that don’t align with organizational standards
- Windows features: Enabling or disabling built-in Windows capabilities
- System settings: Registry modifications, service configurations, and security policies
- Localization: Regional settings, timezone, and language preferences
- Branding: OEM information and organizational identity
- Payloads: Deploying files, scripts, or configuration options to the device
There are multiple ways to implement a DSC package, from simple PowerShell scripts to comprehensive solutions with external configuration files. The approach you choose depends on your organization’s complexity, the need for reusability, and maintenance considerations.
Common use cases include standardizing user experience across corporate devices, security hardening by removing trialware and unnecessary services, regulatory compliance (GDPR, HIPAA), and department-specific configurations tailored to HR, Finance, or Engineering needs.
Introducing Windows gecko
To demonstrate these concepts in practice, let me introduce Windows gecko - a community tool I maintain and use in nearly all Windows Autopilot implementations I have been involved in.
GitHub - dotjesper/windows-gecko: This repository contains the …
This repository contains the source code for Windows gecko. Windows gecko is a multifunctional script designed to adapt to various Windows management …
Geckos are small, adapt to the surroundings and have excellent night vision. Like its namesake, Windows gecko is small in size, adapts to multiple Windows management environments, and uses “clicking sounds” (detailed logging) to ensure every step is checked and recorded.
Windows gecko features
Windows gecko is actively maintained with new functionality added regularly. Current features include:
- Windows Apps: Remove Windows In-box Apps and Store Apps.
- Windows Branding: Configure OEM information and Registration (PREVIEW)
- Windows Features:
- Enable and/or disable Windows features.
- Enable and/or disable Windows optional features.
- Windows Groups: Add accounts to local groups (Coming soon).
- Windows Files: Copy file(s) to device from payload package.
- Windows Registry: Modifying Windows registry entries (add, change, and remove).
- Windows Run: Run local executables and/or download and run executables.
- Windows Services: Configure/re-configure Windows Services.
- Windows TCR: Windows Time zone, Culture and Regional settings manager (PREVIEW).
Requirements
Windows gecko is developed and tested for Windows 11 24H2 Pro and Enterprise 64-bit/ARM-64, and newer and requires PowerShell 5.1.
Note
Windows gecko should run in either SYSTEM or USER context - not both. SYSTEM context requires local administrative rights. Combining contexts is inadvisable and may cause undesired results.Applying a DSC package during Windows Autopilot enrollment
The following steps describe my preferred deployment method: packaging the DSC script as a Win32 app in Microsoft Intune.
This approach provides better control over installation behaviour, detection rules, and assignment options compared to deploying as a platform script. Platform scripts also have a key limitation: they only support a single script file and cannot include configuration files or other payloads.
Step 1: Prepare your DSC configuration
First, create or customize your configuration files. If you’re using Windows gecko, the repository structure looks like this:
📂 solution
├── 📦 assets.zip # Payload files (optional)
├── 📄 configC.json # Configuration for SYSTEM context
├── 📄 configU.json # Configuration for USER context
└── 📜 gecko.ps1 # Main scriptWindows gecko solution folder structure
The configuration files (JSON) define what actions the script should perform.
Configuration options for SYSTEM context
The following configuration options are available when running Windows gecko in SYSTEM context (requires local administrative rights):
- Remove pre-installed apps: Use the
windowsAppssection to remove Windows In-box Apps and Store Apps system-wide (e.g., Xbox, Clipchamp, Microsoft News). - Configure Windows features: Enable or disable built-in Windows capabilities using the
windowsFeaturessection. - Deploy files: Use the
windowsFilessection to copy files from the payload package to system locations on the device. - Registry modifications: Apply registry settings via the
windowsRegistrysection. SYSTEM context supports both system registry (HKLM) and the default user profile registry, ensuring new users inherit your configured settings. - Run scripts or executables: Use the
windowsRunsection to execute local or downloaded scripts/programs with elevated privileges. - Configure services: Adjust Windows service startup types using the
windowsServicessection. - Configure Timezone, Culture, and Regional settings: Use the
windowsTCRsection to set timezone, locale, and keyboard layout. - Configure branding: Use the
windowsBrandingsection to set OEM information and registration details. - Add accounts to local groups: Use the
windowsGroupssection to manage local group membership (Coming soon).
Configuration options for USER context
The following configuration options are available when running Windows gecko in USER context:
- Remove user-provisioned apps: Use the
windowsAppssection to remove Store Apps provisioned for the current user. - Deploy files: Use the
windowsFilessection to copy files from the payload package to user-accessible locations. - Registry modifications: Apply registry settings via the
windowsRegistrysection. USER context writes to the current user registry (HKCU) only. - Run scripts or executables: Use the
windowsRunsection to execute scripts/programs in the user’s security context. - Configure Timezone, Culture, and Regional settings: Use the
windowsTCRsection to configure user-specific regional settings, though some options (such as system timezone) require SYSTEM context.
Note
Each configuration section is optional. If a section is not present in the configuration file, or if itsenabled property is set to false, that section will be skipped during execution. This allows you to include only the configurations relevant to your deployment scenario.Tip
Sample configurations are available in the Windows gecko GitHub repository . Start with these and customize for your organization’s needs - the configuration files are well-documented with comments explaining each setting.Note
Windows gecko supports downloading configuration files from external sources such as GitHub repositories. This can be useful during testing, as you can update the configuration without repackaging the.intunewin file. However, for production deployments, I recommend including all configuration files and payloads directly in the .intunewin package to ensure reliability and avoid external dependencies.Step 2: Create the .intunewin package
To deploy the DSC package via Microsoft Intune, you need to wrap the PowerShell script and payload files into an .intunewin package using the Microsoft Win32 Content Prep Tool .
Download the IntuneWinAppUtil.exe tool.
Organize your source files in a folder structure:
📂 source ├── 📜 gecko.ps1 ├── 📄 configC.json └── 📦 assets.zipRun the content prep tool:
IntuneWinAppUtil.exe -c "C:\source" -s "gecko.ps1" -o "C:\output"This creates a
gecko.intunewinfile ready for upload to Microsoft Intune.
Step 3: Upload the package to Microsoft Intune
- Sign in to the Microsoft Intune admin center .
- Navigate to Apps > All apps > Add.
- Select Windows app (Win32) as the app type.
- Upload the
.intunewinpackage file. - Configure the app information:
- Name: Windows Desired State Configuration (or similar)
- Description: Applies baseline configuration to Windows devices
- Publisher: Your organization
Step 4: Configure the program settings
Configure the install and uninstall commands:
- Install command:
powershell.exe -NoLogo -ExecutionPolicy Bypass -File ".\gecko.ps1" -configFile ".\configC.json" - Uninstall command:
powershell.exe -NoLogo -ExecutionPolicy Bypass -File ".\gecko.ps1" -configFile ".\configC.json" -uninstall - Install behavior: System
- Device restart behavior: No specific action
Tip
32-bit vs 64-bit PowerShell: The Microsoft Intune Management Extension runs PowerShell scripts in 32-bit mode by default. This refers to the PowerShell execution context, not the Windows OS architecture - Windows 11 is 64-bit only, but the Intune Management Extension still launches PowerShell in 32-bit mode by default.
Windows gecko handles this automatically - if the runScriptIn64bitPowerShell property in your configuration is set to true (the default), the script will detect the 32-bit environment and relaunch itself in 64-bit PowerShell. This ensures registry operations target the correct hive and 64-bit cmdlets are available. Only set this to false if you specifically require 32-bit execution.
Alternatively, you can use the sysnative path in your install command to run 64-bit PowerShell directly:
%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -NoLogo -ExecutionPolicy Bypass -File "gecko.ps1" -configFile "configC.json"The sysnative virtual folder is a special alias that allows 32-bit processes to access the native 64-bit System32 folder. This approach runs the script in 64-bit PowerShell immediately, avoiding the relaunch overhead. However, Windows gecko handles both scenarios gracefully, so using the standard powershell.exe command works equally well.
Note
The-uninstall parameter is currently a placeholder in Windows gecko. The uninstall functionality is planned for a future release. For now, the uninstall command will run without performing any actions.Step 5: Configure detection rules
Create a detection rule to verify successful installation. Options include:
- File-based detection: Check for the existence of a log file or marker file created by the script.
- Registry-based detection: Check for a registry key set by the script upon completion.
Windows gecko uses the Windows uninstall registry area to register each configuration as an installed application. The GUID is defined in the JSON configuration file, allowing each configuration to have its own unique install entry. This approach makes the script multipurpose - you can deploy multiple DSC configurations to the same device, each tracked independently - and is designed to support future uninstall functionality.
Example registry detection rule for Windows gecko:
- Key path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{your-config-guid} - Value name:
Version - Detection method: String comparison
- Value: The version defined in your configuration file
The {your-config-guid} should match the guid value within the metadata section specified in your JSON configuration file.
{
"metadata": {
"enabled": true,
"installBehavior": "SYSTEM",
"guid": "{DC34940C-EAAC-4E24-B84A-B405871451AC}",
"title": "Windows gecko-DSC-SYSTEM",
"description": "Windows desired state configuration",
"url": "",
"version": "1.7.0.2",
"date": "2023-11-07",
"publisher": "dotjesper.com",
"developer": "Jesper Nielsen"
},
"runConditions": {
"runScriptIn64bitPowerShell": true,
"requireReboot": false
}
...
}Example JSON configuration snippet for Windows gecko
Note
Theenabled property in the metadata section must be set to true for the registry-based detection to work. When set to false, the registry settings will not be applied, which is useful for other deployment scenarios (e.g., SCCM/ConfigMgr) or during test deployments where you don’t want to register the configuration as installed.Step 6: Assign the package
- Navigate to the Assignments tab.
- Under Required, click Add group and select the device groups that should receive the DSC package. For Windows Autopilot scenarios, assign to the same device groups used for your Autopilot deployment profiles.
- Click Edit assignment (or the three dots) to configure the assignment settings:
- App availability: Set to As soon as possible to ensure the package downloads during enrollment.
- App install deadline: Set to As soon as possible.
- Delivery optimization priority: Set to Content download in foreground to prioritize the download during the Enrollment Status Page.
- End user notifications: Set to Hide all toast notifications to avoid interrupting the user experience during enrollment.
- Click OK to save the assignment settings, then Save the assignments.
Step 7: Configure Enrollment Status Page (ESP)
To ensure the DSC package is applied before the user reaches the desktop, configure the Enrollment Status Page:
- Navigate to Devices > Enrollment > Windows > Enrollment Status Page.
- Select your ESP profile (or create a new one if needed).
- Ensure Show app and profile configuration progress is set to Yes.
- Set Block device use until all apps and profiles are installed to Yes (or use the selective blocking option below).
- Under Block device use until required apps are installed if they are assigned to the user/device, click Select apps.
- Add your DSC package (Windows Desired State Configuration) to the blocking apps list.
- Click Save to apply the ESP configuration.
Important
Adding the DSC package to the ESP blocking apps list ensures the device configuration is complete before the user reaches the desktop. This is critical for Windows Autopilot scenarios where baseline configurations must be applied during provisioning.Monitoring the deployment
After deploying your DSC package, it’s important to verify that installations complete successfully across your device fleet. There are two primary ways to monitor the deployment: through the Microsoft Intune admin center and by reviewing log files on the device.
Microsoft Intune admin center
Monitor the deployment status in the Microsoft Intune admin center:
- Navigate to Apps > All apps > select your DSC app.
- Review the Device install status and User install status reports.
Local log files
Windows gecko creates detailed log files for troubleshooting:
- Default log location:
%ProgramData%\Microsoft\IntuneManagementExtension\Logs\ - Custom log location: Specify using the
-logFileparameter
Note
The default log location is not writable when Windows gecko runs in USER context. Unless you specify a writable custom location using the-logFile parameter, the script automatically redirects the log file to the user’s %TEMP% folder.The Microsoft Intune Management Extension (IME) logs are also helpful:
%ProgramData%\Microsoft\IntuneManagementExtension\Logs\IntuneManagementExtension.log
Troubleshooting common issues
If you encounter problems when deploying Windows gecko, here are common issues and solutions:
Apps not removed as expected:
- Context mismatch: Ensure you’re running in the correct context (SYSTEM vs USER) for the target apps
- App package names: Verify the package names in your configuration match the actual installed apps
- Timing during Autopilot: The DSC package may run before certain apps are provisioned
Configuration not applied:
- JSON syntax errors: Validate your configuration files are valid JSON
- Permission issues: Ensure the script has sufficient permissions for the requested operations
- Review logs: Check the Windows gecko log file for specific error messages
Best practices
Over the years, I’ve found these practices help ensure successful DSC deployments:
- Keep configurations modular: Create reusable configuration modules for common tasks to simplify updates and maintenance.
- Test thoroughly: Validate DSC packages in a staging environment before rolling out to production.
- Use version control: Store scripts and configuration files in a version-controlled repository to track changes and enable rollback.
- Code signing: Sign your PowerShell scripts for production deployments to ensure integrity and meet security requirements.
- Monitor compliance: Use monitoring tools and Microsoft Intune reports to verify devices maintain their desired state.
- Document configurations: Maintain clear documentation for each DSC package, including the rationale for included settings.
Conclusion
Applying DSC packages during Windows Autopilot enrollment enables IT admins to deliver secure, consistent, and compliant devices from day one. By automating baseline configurations, organizations reduce manual effort, speed up deployments, and ensure every device meets their standards.
GitHub - dotjesper/windows-gecko: This repository contains the …
This repository contains the source code for Windows gecko. Windows gecko is a multifunctional script designed to adapt to various Windows management …
Whether you use Windows gecko or build your own solution, the key is establishing a consistent baseline that aligns with your organization’s requirements. Feel free to fork the project and adapt it to your needs - and reach out if you have questions or suggestions.
–Jesper
Header image attribution: Image created with help from Microsoft Copilot


