Skip to content

Instantly share code, notes, and snippets.

Last active January 9, 2019 20:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Enable Windows Sandbox.
This script will simply enable the Windows Sandbox for the user.
Author: Peter van der Woude
Date published: 07-01-2019
Current version: 1.0
#Set variables as input for the script
$WindowsFeature = "Containers-DisposableClientVM"
try {
#Get the state of the Windows Feature
$WindowsFeatureState = (Get-WindowsOptionalFeature -FeatureName $WindowsFeature -Online).State
catch {
Write-Error "Failed to get the state of $WindowsFeature"
#Verify if the Windows Feature is enabled
if($WindowsFeatureState -eq "Enabled") {
Write-Output "$WindowsFeature is enabled"
else {
try {
#Enable the Windows Feature
Enable-WindowsOptionalFeature -FeatureName $WindowsFeature -Online -NoRestart -ErrorAction Stop
Write-Output "Successfully enabled $WindowsFeature"
catch {
Write-Error "Failed to enable $WindowsFeature"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment