Sandbox

Sadbox configuration.

Introduction

This article shows how to install M365 DSC in a Windows Sandbox environment.

Getting Started

The following components will be installed.

  • Install winget
  • Install Nuget Provider
  • PowerShell
  • PowerShell Execution Policy
  • Microsoft 365 DSC
  • PNP.PowerShell
  • All together

Sandbox fixes

Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 8.8.8.8
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy" -Name "VerifiedAndReputablePolicyState" -Value "0"
CiTool.exe --refresh --json

Link

Install winget

$progressPreference = 'silentlyContinue'
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
Repair-WinGetPackageManager -AllUsers
Write-Host "Done."

Link

Install Nuget Provider

Install-PackageProvider -Name "NuGet" -Force

Link

Install PowerShell

winget install Microsoft.Powershell --accept-source-agreements --source winget

Link

Install Windows Terminal

# winget install Microsoft.WindowsTerminal --accept-source-agreements
winget download Microsoft.WindowsTerminal
$msix = Get-ChildItem ".\Downloads\Microsoft.WindowsTerminal*\*.msix"
$depmsix = Get-ChildItem ".\Downloads\Microsoft.WindowsTerminal*\Dependencies\*.msix"
Add-AppxPackage $msix.FullName -DependencyPath $depmsix.FullName

PowerShell Execution Policy

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force

Install Microsoft 365 DSC

This commands have to be run in PowerShell 5.1

Install-Module Microsoft365DSC -Force
Update-M365DSCModule

Link

Install PNP.PowerShell

This commands have to be run in PowerShell 5.1

Install-Module PnP.PowerShell -Force -Scope AllUsers

Link

Install PSDesiredStateConfiguration

Install-Module PSDesiredStateConfiguration -Force

Link

All together

$progressPreference = 'silentlyContinue'
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
Repair-WinGetPackageManager
Write-Host "Done."
Install-PackageProvider -Name "NuGet" -Force
winget install Microsoft.Powershell --accept-source-agreements
winget download Microsoft.WindowsTerminal
$msix = Get-ChildItem ".\Downloads\Microsoft.WindowsTerminal*\*.msix"
$depmsix = Get-ChildItem ".\Downloads\Microsoft.WindowsTerminal*\Dependencies\*.msix"
Add-AppxPackage $msix.FullName -DependencyPath $depmsix.FullName
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
Install-Module Microsoft365DSC -Force
Update-M365DSCModule
Install-Module PnP.PowerShell -Force -Scope AllUsers
Install-Module PSDesiredStateConfiguration -Force