{"id":16567495,"url":"https://github.com/jdhitsolutions/windowssandboxtools","last_synced_at":"2025-03-16T20:31:00.495Z","repository":{"id":46729830,"uuid":"290834928","full_name":"jdhitsolutions/WindowsSandboxTools","owner":"jdhitsolutions","description":":camel: My PowerShell scripts and tools for setting up and configuring the Windows Sandbox","archived":false,"fork":false,"pushed_at":"2023-06-21T14:37:09.000Z","size":11872,"stargazers_count":71,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-10T19:57:22.282Z","etag":null,"topics":["powershell","windows-sandbox"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdhitsolutions.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-27T17:07:39.000Z","updated_at":"2025-03-02T16:10:24.000Z","dependencies_parsed_at":"2024-10-27T11:13:41.603Z","dependency_job_id":"820b7f95-e7e8-45c2-be79-927e20c75a27","html_url":"https://github.com/jdhitsolutions/WindowsSandboxTools","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FWindowsSandboxTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FWindowsSandboxTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FWindowsSandboxTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FWindowsSandboxTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdhitsolutions","download_url":"https://codeload.github.com/jdhitsolutions/WindowsSandboxTools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["powershell","windows-sandbox"],"created_at":"2024-10-11T21:06:44.733Z","updated_at":"2025-03-16T20:31:00.174Z","avatar_url":"https://github.com/jdhitsolutions.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows Sandbox Tools\n\n![sandbox](images/sandbox.jpg)\n\n[![PSGallery Version](https://img.shields.io/powershellgallery/v/WindowsSandboxTools.png?style=for-the-badge\u0026label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/WindowsSandboxTools/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/WindowsSandboxTools.png?style=for-the-badge\u0026label=Downloads)](https://www.powershellgallery.com/packages/WindowsSandboxTools/)\n\nThis repository is a collection of PowerShell tools and scripts that I use to run and configure the Windows Sandbox feature that was introduced in Windows 10 2004. Many of the commands in this repository were first demonstrated on my [blog](https://jdhitsolutions.com/blog/powershell/7621/doing-more-with-windows-sandbox/). I strongly recommend you read the blog post before trying any of the code. As I mention in the blog post, most of the code here will __reduce the security__ of the Windows Sandbox application. This is a trade-off I am willing to make for the sake of functionality that meets *my* requirements. You have to decide how much of the code you would like to use.\n\n__*All code is offered as-is with no guarantees. Nothing in this repository should be considered production-ready or used in critical environments without your extensive testing and validation.*__\n\n## Installing the Windows Sandbox\n\nYou need to have the 2004 version of Windows 10 or later. The Windows Sandbox will run a containerized version of your operating system. I don't know off-hand if it is supported on Windows 10 Home or Education editions. Otherwise, you should be able to run these PowerShell commands to get started:\n\n```powershell\nGet-WindowsOptionalFeature -Online -FeatureName Containers-DisposableClientVM\nEnable-WindowsOptionalFeature -Online -FeatureName Containers-DisposableClientVM\n```\n\n## The WindowsSandBoxTools Module\n\nI have created a PowerShell module called `WindowsSandBoxTools`. In this module are functions designed to make it easier to view a `wsb` configuration, create a new configuration, and export a configuration to a file. The module functions use several PowerShell class definitions.\n\nYou can read the Microsoft documentation on creating a Windows Sandbox configuration at [https://docs.microsoft.com/windows/security/threat-protection/windows-sandbox/windows-sandbox-configure-using-wsb-file](https://docs.microsoft.com/windows/security/threat-protection/windows-sandbox/windows-sandbox-configure-using-wsb-file). The module commands are designed to abstract the process of creating the XML configuration files which have a `.wsb` extension.\n\nInstall the module from the PowerShell Gallery.\n\n```powershell\nInstall-Module WindowsSandboxTools\n```\n\nThe module should work in Windows PowerShell and PowerShell 7 on Windows platforms.\n\n### [Start-WindowsSandbox](docs/Start-WindowsSandbox.md)\n\nThe [`Start-WindowsSandbox`](docs/Start-WindowsSandbox.mx) function is my primary tool. It has an alias of `wsb`. You can specify the path to the wsb file.\n\n![Start-WindowsSandbox](images/start-windowssandbox.png)\n\nIf you use the `NoSetup` parameter, it will launch the default Windows Sandbox. In either usage, you can specify display dimensions for the sandbox. The `WindowSize` parameter expects an array of width and height, like 1024,768. My default is 1920,1080. You may have to drag the window slightly to force the sandbox to redraw the screen and remove the horizontal scrollbar. Setting the display is tricky, and I don't know if what I am using will work for everyone, so if you don't get the results you expect, please post an issue.\n\nThe sandbox will start and then minimize while any configurations you may have are executed.\n\n### [Get-WsbConfiguration](docs/Get-WsbConfiguration.md)\n\nIf you have created custom configurations, or intend to use the samples from this module, `Get-WsbConfiguration` will display information about the configuration.\n\n```text\nPS C:\\\u003e Get-WsbConfiguration d:\\wsb\\simple.wsb\nWARNING: No value detected for LogonCommand. This may be intentional on your part.\n\n\n   Name: Simple\n\nvGPU                 : Enable\nMemoryInMB           : 8192\nAudioInput           : Default\nVideoInput           : Default\nClipboardRedirection : Default\nPrinterRedirection   : Default\nNetworking           : Default\nProtectedClient      : Default\nLogonCommand         :\nMappedFolders        : C:\\scripts -\u003e C:\\scripts [RO:False]\n```\n\nThe command uses a custom format file to display the configuration. I have also found a way to insert metadata into the wsb file which (so far) doesn't appear to interfere with the Windows Sandbox application.\n\n```text\nPS C:\\\u003e Get-WsbConfiguration d:\\wsb\\simple.wsb -MetadataOnly\n\nAuthor     Name   Description                                       Updated\n------     ----   -----------                                       -------\nJeff Hicks Simple a simple configuration with mapping to C:\\Scripts 12/10/2021 8:50:03 AM\n```\n\n### [New-WsbConfiguration](docs/New-WsbConfiguration.md)\n\nThis is how you can create a new Windows Sandbox configuration.\n\n```powershell\n$params = @{\n Networking = \"Default\"\n LogonCommand = \"c:\\data\\demo.cmd\"\n MemoryInMB = 2048\n PrinterRedirection = \"Disable\"\n MappedFolder = (New-WsbMappedFolder -HostFolder d:\\data -SandboxFolder c:\\data -ReadOnly)\n Name = \"MyDemo\"\n Description = \"A demo WSB configuration\"\n}\n$new = New-WsbConfiguration  @params\n```\n\nThe `LogonCommand` value is relative to the WindowsSandbox. This code will create a `wsbConfiguration` object.\n\n```text\n\n   Name: MyDemo\n\nvGPU                 : Default\nMemoryInMB           : 2048\nAudioInput           : Default\nVideoInput           : Default\nClipboardRedirection : Default\nPrinterRedirection   : Disable\nNetworking           : Default\nProtectedClient      : Default\nLogonCommand         : c:\\data\\demo.cmd\nMappedFolders        : d:\\data -\u003e c:\\data [RO:True]\n```\n\nYou could modify this object as necessary.\n\n```powershell\n$new.vGPU = \"Enable\"\n$new.Metadata.Updated = Get-Date\n```\n\nThe last step is to export the configuration to a `wsb` file.\n\n```powershell\n$new | Export-WsbConfiguration -Path d:\\wsb\\demo.wsb\n```\n\nWhich will create this file:\n\n```xml\n\u003cConfiguration\u003e\n  \u003cMetadata\u003e\n    \u003cName\u003eMyDemo\u003c/Name\u003e\n    \u003cAuthor\u003eJeff\u003c/Author\u003e\n    \u003cDescription\u003eA demo WSB configuration\u003c/Description\u003e\n    \u003cUpdated\u003e07/10/2022 15:40:54\u003c/Updated\u003e\n  \u003c/Metadata\u003e\n  \u003cvGPU\u003eEnable\u003c/vGPU\u003e\n  \u003cMemoryInMB\u003e2048\u003c/MemoryInMB\u003e\n  \u003cAudioInput\u003eDefault\u003c/AudioInput\u003e\n  \u003cVideoInput\u003eDefault\u003c/VideoInput\u003e\n  \u003cClipboardRedirection\u003eDefault\u003c/ClipboardRedirection\u003e\n  \u003cPrinterRedirection\u003eDisable\u003c/PrinterRedirection\u003e\n  \u003cNetworking\u003eDefault\u003c/Networking\u003e\n  \u003cProtectedClient\u003eDefault\u003c/ProtectedClient\u003e\n  \u003cLogonCommand\u003e\n    \u003cCommand\u003ec:\\data\\demo.cmd\u003c/Command\u003e\n  \u003c/LogonCommand\u003e\n  \u003cMappedFolders\u003e\n    \u003cMappedFolder\u003e\n      \u003cHostFolder\u003ed:\\data\u003c/HostFolder\u003e\n      \u003cSandboxFolder\u003ec:\\data\u003c/SandboxFolder\u003e\n      \u003cReadOnly\u003eTrue\u003c/ReadOnly\u003e\n    \u003c/MappedFolder\u003e\n  \u003c/MappedFolders\u003e\n\u003c/Configuration\u003e\n```\n\nI can easily launch this configuration.\n\n```powershell\nStart-WindowsSandbox -Configuration D:\\wsb\\demo.wsb\n```\n\n### [New-WsbMappedFolder](docs/New-WsbMappedFolder.md)\n\nUse this command to create a mapped folder object.\n\n```powershell\n$map = New-WsbMappedFolder -HostFolder c:\\work -SandboxFolder c:\\work\n```\n\nOnce created, you can use this in a new configuration.\n\n```powershell\nNew-WsbConfiguration -Name work -MappedFolder $map -Description \"Work sandbox\"\n```\n\n### [Export-WSBConfiguration](docs/Export-WsbConfiguration.md)\n\nAfter you have created a new configuration, you will want to save it to a file.\n\n```powershell\nNew-WsbConfiguration -Name work -LogonCommand \"$wsbScripts\\basic.cmd\" -MemoryInMB (4096*2) -MappedFolder (New-WsbMappedFolder -HostFolder d:\\work -SandboxFolder c:\\work) -Description \"My work WSB configuration\" | Export-WsbConfiguration -Path \"$wsbConfigPath\\work.wsb\"\n```\n\nThe exported file must have a `.wsb` file extension. Save the file to your `$wsbConfigPath` location.\n\nYou should get a file like this:\n\n```xml\n\u003cConfiguration\u003e\n  \u003cMetadata\u003e\n    \u003cName\u003ework\u003c/Name\u003e\n    \u003cAuthor\u003eJeff\u003c/Author\u003e\n    \u003cDescription\u003eMy work WSB configuration\u003c/Description\u003e\n    \u003cUpdated\u003e07/18/2022 15:43:24\u003c/Updated\u003e\n  \u003c/Metadata\u003e\n  \u003cvGPU\u003eDefault\u003c/vGPU\u003e\n  \u003cMemoryInMB\u003e8192\u003c/MemoryInMB\u003e\n  \u003cAudioInput\u003eDefault\u003c/AudioInput\u003e\n  \u003cVideoInput\u003eDefault\u003c/VideoInput\u003e\n  \u003cClipboardRedirection\u003eDefault\u003c/ClipboardRedirection\u003e\n  \u003cPrinterRedirection\u003eDefault\u003c/PrinterRedirection\u003e\n  \u003cNetworking\u003eDefault\u003c/Networking\u003e\n  \u003cProtectedClient\u003eDefault\u003c/ProtectedClient\u003e\n  \u003cLogonCommand\u003e\n    \u003cCommand\u003eC:\\scripts\\windowssandboxtools\\wsbScripts\\basic.cmd\u003c/Command\u003e\n  \u003c/LogonCommand\u003e\n  \u003cMappedFolders\u003e\n    \u003cMappedFolder\u003e\n      \u003cHostFolder\u003ec:\\work\u003c/HostFolder\u003e\n      \u003cSandboxFolder\u003ec:\\work\u003c/SandboxFolder\u003e\n      \u003cReadOnly\u003eFalse\u003c/ReadOnly\u003e\n    \u003c/MappedFolder\u003e\n  \u003c/MappedFolders\u003e\n\u003c/Configuration\u003e\n```\n\n## My Configuration Scripts\n\nMy default [configuration script](wsbScripts/demo-config.ps1) takes about 4 minutes to complete. I use the [BurntToast](https://github.com/Windos/BurntToast) module to show a Windows Action Center notification when it is complete.\n\nWhen you import the module, it will define two global variables. `$wsbConfigPath` points to the location of your wsb files. `$wsbScripts` points to the location of your supporting scripts. By default, these variables will point to directories in the module root. You will most like want to update these variables to point to your location. I set this in my PowerShell profile script.\n\n__You need to verify and update path references if you use any of the configurations or scripts in this module.__\n\n## RoadMap\n\nThis is a list of items I'd like to address or handle more efficiently:\n\n+ Look for a way to organize script components used for `LogonCommand` settings.\n+ Use a default shared folder that can be a bit more generic.\n+ Add a better way to provide or integrate toast notifications.\n+ Create a graphical interface for creating configurations.\n\nFeel free to post enhancment suggestions in Issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2Fwindowssandboxtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdhitsolutions%2Fwindowssandboxtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2Fwindowssandboxtools/lists"}