This project sets up Windows Docker containers with Windows Server Core 2022 and tests different Chef versions (18.8.11 vs 18.8.46) by installing them via Omnitruck and running a test recipe.
- Windows 10/11 or Windows Server with Docker Desktop installed
- Docker configured for Windows containers
- PowerShell 5.1 or later
.
+-- Dockerfile # Windows Server Core 2022 with Chef installation
+-- docker-compose.yml # Multi-container setup for both Chef versions
+-- run-test.ps1 # Main test script
+-- cookbooks/
+-- test_recipe/
+-- metadata.rb # Recipe metadata
+-- recipes/
+-- default.rb # Test recipe that outputs Chef version
+-- shared/ # Mounted volume for output files
+-- chef-{version}.txt # Generated by containers
Run the main test script with default versions:
.\run-test.ps1Or specify custom Chef versions:
.\run-test.ps1 -ChefVersion1 "18.8.11" -ChefVersion2 "18.8.46".\run-test.ps1 -ChefVersion1 "18.8.11" -SingleVersionPlace your Chef MSI file in the project root and run:
.\run-test.ps1 -MsiFile "chef-18.8.11-1-x64.msi"Or with a full path:
.\run-test.ps1 -MsiFile "C:\downloads\chef-18.8.11-1-x64.msi"Search for DLLs without running dumpbin:
.\run-test.ps1 -FindDLLsSearch for DLLs and analyze Chef.PowerShell.Wrapper.dll with dumpbin:
.\run-test.ps1 -FindDLLs -UseDumpbinThe script will search for the following DLLs:
- KERNEL32.dll
- VCRUNTIME140.dll
- api-ms-win-crt-runtime-l1-1-0.dll
- api-ms-win-crt-heap-l1-1-0.dll
- MSVCP140.dll
- mscoree.dll
Note: Using -UseDumpbin will install Visual Studio Build Tools (~6GB) which significantly increases build time. Use this only when you need detailed dependency analysis.
# Build both images
docker-compose build
# Run both containers
docker-compose up
# Check results
Get-ChildItem .\shared\chef-*.txt | ForEach-Object { Write-Host "=== $($_.Name) ==="; Get-Content $_ }# Create shared directory
New-Item -ItemType Directory -Path .\shared -Force
# Build and run Chef 18.8.11
docker build --build-arg CHEF_VERSION=18.8.11 -t chef-test:18.8.11 .
docker run --rm -v "${PWD}\shared:C:\shared" -v "${PWD}\cookbooks:C:\cookbooks" chef-test:18.8.11 powershell -Command "chef-client -z -o recipe[test_recipe] --chef-license accept-silent"
# Build and run Chef 18.8.46
docker build --build-arg CHEF_VERSION=18.8.46 -t chef-test:18.8.46 .
docker run --rm -v "${PWD}\shared:C:\shared" -v "${PWD}\cookbooks:C:\cookbooks" chef-test:18.8.46 powershell -Command "chef-client -z -o recipe[test_recipe] --chef-license accept-silent"
# Check results
Get-ChildItem .\shared\chef-*.txt | ForEach-Object { Get-Content $_ }- Creates Shared Volume: Sets up a directory for output files
- Builds Docker Images: Creates Windows Server Core 2022 images with specified Chef versions installed via:
- Omnitruck (default for version numbers)
- MSI file (when using -MsiFile parameter)
- Runs Containers: Executes Chef client in zero mode with the test recipe
- Searches for DLLs (optional, with -FindDLLs flag):
- Chef.PowerShell.Wrapper.dll (in C:\opscode\chef)
- KERNEL32.dll
- VCRUNTIME140.dll
- api-ms-win-crt-runtime-l1-1-0.dll
- api-ms-win-crt-heap-l1-1-0.dll
- MSVCP140.dll
- mscoree.dll
- Runs dumpbin (optional, with -UseDumpbin flag): Analyzes Chef.PowerShell.Wrapper.dll dependencies
- Test Recipe Execution: The recipe runs a PowerShell script that:
- Retrieves the current Chef version
- Optionally searches for DLLs and runs diagnostic tools
- Outputs version and diagnostic information to a file on the shared volume
- File is named
chef-{version}.txt
- Validates Results: Checks the shared volume for output files and displays their contents
Compare two Chef versions installed via Omnitruck:
.\run-test.ps1 -ChefVersion1 "18.8.11" -ChefVersion2 "18.8.46"Test a single Chef version:
.\run-test.ps1 -ChefVersion1 "17.10.0" -SingleVersionTest a Chef MSI installer:
.\run-test.ps1 -MsiFile "chef-18.8.11-1-x64.msi"Test with DLL search (fast):
.\run-test.ps1 -FindDLLsTest with DLL search and dumpbin analysis (slow, installs VS Build Tools):
.\run-test.ps1 -FindDLLs -UseDumpbinCombine with MSI testing:
.\run-test.ps1 -MsiFile "chef-18.8.11-1-x64.msi" -FindDLLs -UseDumpbinEach container generates a file named chef-{version}.txt in the shared directory containing:
- Chef version
- Installation method (Omnitruck or MSI)
- Computer name (container name)
- Timestamp
- Chef client path
- Chef.PowerShell.Wrapper.dll search results (if -FindDLLs is used)
- Other DLL search results (if -FindDLLs is used)
- Dumpbin dependency analysis (if -UseDumpbin is used)
Example output file content:
Chef Version: 18.8.11
Installation Method: Omnitruck
Computer Name: CONTAINER123
Timestamp: 2025-10-22 10:30:45
Chef Client Path: C:\opscode\chef\bin\chef-client
Chef.PowerShell.Wrapper.dll Search Results (Pre-Chef Run):
Path: C:\opscode\chef\embedded\lib\ruby\gems\3.1.0\gems\chef-powershell-18.1.0\bin\ruby_bin_folder\AMD64\Chef.PowerShell.Wrapper.dll
Size: 12345 bytes
LastWriteTime: 10/22/2025 10:15:30
Dumpbin Output:
Microsoft (R) COFF/PE Dumper Version 14.35.32215.0
...
DLL Search Results:
KERNEL32.dll found at:
C:\Windows\System32\KERNEL32.dll
VCRUNTIME140.dll found at:
C:\opscode\chef\embedded\bin\VCRUNTIME140.dll
...
Switch Docker to Windows containers:
& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemonEnsure you have internet access and TLS 1.2 is enabled:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12Check Docker is running and Windows containers are available:
docker info
docker versionTo test different Chef versions, modify the run-test.ps1 parameters or update docker-compose.yml:
args:
CHEF_VERSION: "17.10.0" # Change to desired versionTests chef-powershell gem installation in a Windows Server Core 2022 Docker container with Ruby installed via RubyInstaller2. This script is useful for testing chef-powershell gem compatibility with specific Ruby versions without a full Chef installation.
Features:
- Installs Ruby+Devkit from RubyInstaller2 (default: 3.1.7)
- Caches Docker images by Ruby version to avoid re-downloading Ruby on subsequent runs
- Supports installing chef-powershell from RubyGems (specific version or latest)
- Supports installing chef-powershell from a local .gem file
- Runs test suite from
test-chef-ps.rbto validate gem functionality - Provides interactive debugging session in the container after tests complete
Usage:
Install latest chef-powershell:
.\run-ruby-test.ps1Install specific chef-powershell version:
.\run-ruby-test.ps1 -ChefPowerShellVersion "1.0.38"Install from local gem file:
.\run-ruby-test.ps1 -ChefPowerShellGemPath ".\chef-powershell-1.0.38.gem"Use different Ruby version:
.\run-ruby-test.ps1 -RubyVersion "3.2.0"Keep container running after tests:
.\run-ruby-test.ps1 -KeepContainerWhat it does:
- Checks if a Docker image exists for the specified Ruby version
- If not, creates a new image by:
- Starting a Windows Server Core 2022 container
- Downloading and installing Ruby+Devkit with silent installation
- Committing the container as a tagged image (e.g.,
ruby-devkit:3.1.7-windows)
- Installs chef-powershell gem from RubyGems or local file
- Copies and runs
test-chef-ps.rbtest suite - Drops into an interactive PowerShell session for debugging
Tests Chef MSI installations in a Windows Server Core 2022 Docker container and validates chef-powershell functionality using Chef's embedded Ruby.
Features:
- Installs Chef from an MSI file
- Runs a test Chef recipe to verify installation
- Automatically executes
test-chef-ps.rbtest suite using Chef's embedded Ruby - Provides interactive debugging on test failures
- Validates chef-powershell gem works with Chef's embedded Ruby environment
Usage:
Test with Chef MSI file:
.\run-simple-test.ps1 -MsiFile "chef-18.8.11-1-x64.msi"With full path:
.\run-simple-test.ps1 -MsiFile "C:\downloads\chef-18.8.46-1-x64.msi"What it does:
- Creates a Windows Server Core 2022 container with shared volume
- Copies the MSI file into the container
- Installs Chef from the MSI file
- Runs
chef-clientwith a test recipe to verify Chef works - Copies
test-chef-ps.rbto the shared volume - Executes the test suite using Chef's embedded Ruby (
C:\opscode\chef\embedded\bin\ruby.exe) - Reports test results and provides interactive debugging if tests fail
Shared Ruby test suite used by both run-ruby-test.ps1 and run-simple-test.ps1 to validate chef-powershell gem functionality.
Tests performed:
- Lists all installed gems matching 'powershell'
- Displays chef-powershell gem specification (version, authors, install location, etc.)
- Loads the chef-powershell gem
- Executes PowerShell commands via the gem (
Get-Date,Get-Process,Get-ChildItem) - Validates output from PowerShell commands
This modular test file ensures consistent validation across different installation methods (standalone Ruby vs Chef's embedded Ruby).
Remove generated images and containers:
# Remove containers
docker-compose down
# Remove images
docker rmi chef-test:18.8.11 chef-test:18.8.46
docker rmi ruby-devkit:3.1.7-windows
# Clean shared directory
Remove-Item .\shared\chef-*.txt