134 lines
6.1 KiB
Plaintext
134 lines
6.1 KiB
Plaintext
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
|
|
|
|
############################################################################
|
|
# Descripion:
|
|
# This configuration file is intended to bootstrap the packages which are
|
|
# required for the YamlCreate.ps1 script to have full functionality.
|
|
# Although the script will do this automatically, the DSC resource is
|
|
# provided as an alternative way to do the initial setup and as an example
|
|
# or reference for authoring other DSC files.
|
|
#
|
|
# This configuration also installs Visual Studio Code and related
|
|
# extensions as an IDE for easily working with the manifests generated by
|
|
# the YamlCreate.ps1 script.
|
|
############################################################################
|
|
|
|
properties:
|
|
resources:
|
|
########################################################################
|
|
# Section: Install VS-Code
|
|
########################################################################
|
|
- resource: Microsoft.WinGet.DSC/WinGetPackage
|
|
id: install-vs-code
|
|
directives:
|
|
description: Install Microsoft Visual Studio Code
|
|
allowPrerelease: true
|
|
settings:
|
|
id: Microsoft.VisualStudioCode
|
|
source: winget
|
|
Ensure: Present
|
|
- resource: vscode/VSCodeExtension
|
|
dependsOn:
|
|
- install-vs-code
|
|
directives:
|
|
description: Install YAML extension for VSCode
|
|
allowPrerelease: true
|
|
settings:
|
|
Name: redhat.vscode-yaml
|
|
Ensure: Present
|
|
- resource: vscode/VSCodeExtension
|
|
dependsOn:
|
|
- install-vs-code
|
|
directives:
|
|
description: Install EditorConfig extension for VSCode
|
|
allowPrerelease: true
|
|
settings:
|
|
Name: EditorConfig.EditorConfig
|
|
Ensure: Present
|
|
########################################################################
|
|
# Section: Install Packages
|
|
########################################################################
|
|
- resource: Microsoft.WinGet.DSC/WinGetPackage
|
|
id: install-git
|
|
directives:
|
|
description: Install Git # Although the user probably already has git installed, it's possible that they don't
|
|
allowPrerelease: true
|
|
settings:
|
|
id: Git.Git
|
|
source: winget
|
|
Ensure: Present
|
|
- resource: Microsoft.WinGet.DSC/WinGetPackage
|
|
id: install-git-cli
|
|
directives:
|
|
description: Install GitHub CLI
|
|
allowPrerelease: true
|
|
settings:
|
|
id: GitHub.cli
|
|
source: winget
|
|
Ensure: Present
|
|
########################################################################
|
|
# Section: Configure Git Remotes
|
|
########################################################################
|
|
- resource: GitDSC/GitRemote
|
|
id: add-microsoft-upstream
|
|
directives:
|
|
description: Add microsoft/winget-pkgs as the upstream remote
|
|
allowPrerelease: true
|
|
settings:
|
|
ProjectDirectory: '${WinGetConfigRoot}\..'
|
|
RemoteName: upstream
|
|
RemoteUrl: https://github.com/microsoft/winget-pkgs.git
|
|
########################################################################
|
|
# Section: Install PowerShell Modules
|
|
########################################################################
|
|
- resource: PowerShellModule/PSModuleResource
|
|
id: install-powershell-yaml
|
|
directives:
|
|
description: Install powershell-yaml module
|
|
allowPrerelease: true
|
|
settings:
|
|
Module_Name: powershell-yaml
|
|
Ensure: Present
|
|
########################################################################
|
|
# Section: Enable Windows Sandbox
|
|
# Note:
|
|
# Windows Sandbox isn't available on all editions of Windows, which
|
|
# will cause this DSC resource to fail in some cases. It is possible
|
|
# to enable the sandbox by manually registering all the containers
|
|
# packages with DISM and then use DISM again to enable the Windows
|
|
# feature. While DSC is maturing, the script resource has been used
|
|
# to check the privelege level and edition of windows before Sandbox
|
|
# can be enabled using DSC.
|
|
########################################################################
|
|
# - resource: Microsoft.WindowsSandbox.DSC/WindowsSandbox
|
|
# id: install-windows-sandbox
|
|
# directives:
|
|
# description: Enable Windows Sandbox
|
|
# allowPrerelease: true
|
|
# settings:
|
|
# Ensure: Present
|
|
- resource: PSDscResources/Script
|
|
id: install-windows-sandbox
|
|
directives:
|
|
description: Enable Windows Sandbox
|
|
allowPrerelease: true
|
|
settings:
|
|
GetScript: |
|
|
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
if (!$isAdmin) { return @{Result = 'Dism must be run as admin'}}
|
|
@{Result = $((dism /online /Get-Features /Format:Table | Select-String 'Containers-DisposableClientVM').Line.Trim() -split ' ' |Select-Object -Last 1)}
|
|
TestScript: |
|
|
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
$caption = (Get-CimInstance Win32_OperatingSystem).Caption
|
|
$isSandboxApplicable = $caption -match 'Windows (10|11) (Pro|Enterprise|Education)'
|
|
if (!$isAdmin -or !$isSandboxApplicable) {return $false}
|
|
$((dism /online /Get-Features /Format:Table | Select-String 'Containers-DisposableClientVM').Line.Trim() -split ' ' |Select-Object -Last 1) -eq 'Enabled'
|
|
SetScript: |
|
|
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
$caption = (Get-CimInstance Win32_OperatingSystem).Caption
|
|
$isSandboxApplicable = $caption -match 'Windows (10|11) (Pro|Enterprise|Education)'
|
|
if ($isAdmin -and $isSandboxApplicable) {
|
|
dism /online /enable-feature /featurename:Containers-DisposableClientVM /norestart
|
|
}
|
|
configurationVersion: 0.2.0
|