Skip to content

Instantly share code, notes, and snippets.

@adilio
Last active March 30, 2021 08:10
Show Gist options
  • Save adilio/077f8f94f92ba8e1262b661e8b83da18 to your computer and use it in GitHub Desktop.
Save adilio/077f8f94f92ba8e1262b661e8b83da18 to your computer and use it in GitHub Desktop.
Setting up Chocolatey for Business (C4B) with Quick Deployment Environment (QDE) using Desired State Configuration (DSC)

Setting up C4b with QDE using DSC

Setting up Chocolatey for Business (C4B) with Quick Deployment Environment (QDE) using Desired State Configuration (DSC)

Prerequisites

  1. Install NuGet and PowerShellGet, and trust the PowerShell Gallery:
Install-PackageProvider -Name NuGet -Force
Install-Module -Name PowerShellGet -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
  1. Install cChoco DSC Resource:
Install-Module -Name cChoco -Force
  1. Expand maximum envelope size for WSMan (needed for large packages):
Set-WSManInstance -ValueSet @{MaxEnvelopeSizekb="512000"} -ResourceURI winrm/config
  1. Install the QDE server certificate
$downloader = New-Object -TypeName System.Net.WebClient
Invoke-Expression ($downloader.DownloadString('http://chocoserver:80/Import-ChocoServerCertificate.ps1'))
  1. Set Execution Policy to allow scripts:
Set-ExecutionPolicy RemoteSigned
Configuration InstallChoco {
Import-DscResource -Module cChoco
Node "localhost"
{
cChocoInstaller InstallChoco
{
InstallDir = "C:\ProgramData\chocolatey"
ChocoInstallScriptUrl = "https://chocoserver:8443/repository/choco-install/ChocolateyInstall.ps1"
}
cChocoSource ChocolateyInternal
{
Name = 'ChocolateyInternal'
Source = 'https://chocoserver:8443/repository/ChocolateyInternal/'
Priority = 1
Ensure = 'Present'
DependsOn = '[cChocoInstaller]installChoco'
}
cChocoSource CommunityRepo
{
Name = 'Chocolatey'
Ensure = 'Absent'
DependsOn = '[cChocoInstaller]installChoco'
}
cChocoPackageInstaller installLicensePackage
{
Name = 'chocolatey-license'
Ensure = 'Present'
AutoUpgrade = $True
DependsOn = '[cChocoInstaller]installChoco'
}
cChocoPackageInstaller installLicensedExtension
{
Name = 'chocolatey.extension'
Ensure = 'Present'
Params = '/NoContextMenu'
AutoUpgrade = $True
DependsOn = '[cChocoInstaller]installChoco'
}
cChocoPackageInstallerSet installBasePackages
{
Ensure = 'Present'
Name = @(
"chocolateygui"
"chocolatey-agent"
)
DependsOn = "[cChocoInstaller]installChoco"
}
cChocoFeature showNonElevatedWarnings
{
FeatureName = 'showNonElevatedWarnings'
Ensure = 'Absent'
}
cChocoFeature useBackgroundService
{
FeatureName = 'useBackgroundService'
Ensure = 'Present'
}
cChocoFeature useBackgroundServiceWithNonAdministratorsOnly
{
FeatureName = 'useBackgroundServiceWithNonAdministratorsOnly'
Ensure = 'Present'
}
cChocoFeature allowBackgroundServiceUninstallsFromUserInstallsOnly
{
FeatureName = 'allowBackgroundServiceUninstallsFromUserInstallsOnly'
Ensure = 'Present'
}
cChocoConfig CentralManagementServiceUrl
{
ConfigName = 'CentralManagementServiceUrl'
Ensure = 'Present'
Value = 'https://chocoserver:24020/ChocolateyManagementService'
}
cChocoFeature useChocolateyCentralManagement
{
FeatureName = 'useChocolateyCentralManagement'
Ensure = 'Present'
}
cChocoFeature useChocolateyCentralManagementDeployments
{
FeatureName = 'useChocolateyCentralManagementDeployments'
Ensure = 'Present'
}
}
}
$config = InstallChoco
Start-DscConfiguration -Path $config.psparentpath -Wait -Verbose -Force
Configuration InstallPackages {
Import-DscResource -Module cChoco
Node "localhost"
{
cChocoInstaller InstallChoco
{
InstallDir = "c:\ProgramData\chocolatey"
}
cChocoPackageInstaller install7zip
{
Name = '7zip'
Ensure = 'Present'
AutoUpgrade = $True
DependsOn = '[cChocoInstaller]installChoco'
}
cChocoPackageInstallerSet installPackageSet
{
Ensure = 'Present'
Name = @(
"notepadplusplus.install"
"googlechrome"
)
DependsOn = '[cChocoInstaller]installChoco'
}
}
}
$config = InstallPackages
Start-DscConfiguration -Path $config.psparentpath -Wait -Verbose -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment