Skip to content
WindowsSandbox pre-installed PowerShell modules
Home » Pre-installed PowerShell modules in Windows Sandbox

Pre-installed PowerShell modules in Windows Sandbox

The Windows Sandbox is a great tool for testing installations or program behavior. However, such tasks often require PowerShell modules that are not preinstalled. However, PowerShell modules can easily be installed in the Windows Sandbox with a WSB and PS1 file. I use the same structure of the WSB file with the corresponding PowerShell modules in an array for different purposes.

The structure of the WSB file is as follows:

<Configuration> <MappedFolders> <MappedFolder> <HostFolder>C:\GitHub\scloud\Windows-Sandbox</HostFolder> <ReadOnly>true</ReadOnly> </MappedFolder> </MappedFolders> <LogonCommand> <Command>powershell -executionpolicy unrestricted -command "start powershell {-noexit -file C:\Users\WDAGUtilityAccount\Desktop\Windows-Sandbox\APP-Upload.ps1}"</Command> </LogonCommand> </Configuration>
Code language: HTML, XML (xml)

With this configuration (lines 4 & 5), the folder in which the PowerShell installation file is located is mapped into the sandbox in read-only mode.
Line 9 defines that the corresponding PS1 file is started at startup.
The content of this is:

# Array of the PowerShell Modules $PSModules = "ExchangeOnlineManagement", "MicrosoftTeams" # ExecutionPolicy and NuGet Set-ExecutionPolicy Unrestricted -Force Install-PackageProvider -Name NuGet -Force # Install all defined Modules foreach($Module in $PSModules){ Write-Host $Module Install-Module -Name $Module -Force }
Code language: PowerShell (powershell)

In this example I am installing the Exchange Online and Teams module.

As soon as these two files exist, the WSB file can be double-clicked and the sandbox including the module installation starts.
The sample files are also available for download here on my GitHub repo (PS-Modules.ps1 & PS-Modules.wsb): scloud/Windows-Sandbox at main FlorianSLZ/scloud (

I have also created some additional examples that may help:

win32 automatedImport of win32 applications into Intune. (blog post)
HostMachine folderRead/Write access to the local GitHub repo folder and modules "MSOnline", "AzureADPreview"
M365DocumentationTo create the M365 documentation (by Thomas Kur, Github)
PS modulesExample from above
CallFlowDokuVisualization of the teams call flows: demo and explanation

When using my template, it is important to adapt the paths in the WSB file. Otherwise the installation of the PowerShell modules in the Windows sandbox will not work.

I myself often use the included folder option to test program installations, such as my Win32 apps (my take on win32 apps - Intune | scloud).

Activate Windows Sandbox

If opening the sandbox does not work, the Windows feature may have to be activated first.
This can be done under Windows Features or with the following PowerShell:

Enable-WindowsOptionalFeature -FeatureName "Containers-DisposableClientVM" -Online -NoRestart -ErrorAction Stop
Code language: PowerShell (powershell)

1 thought on “Pre-Installed PowerShell Module in Windows Sandbox”

  1. Pingback: win32 App Deployment automated | scloud

Leave a Reply

Your email address will not be published. Required fields are marked *

de_CH DE
de_CH DE
en_US EN
Exit mobile version