Skip to content

Instantly share code, notes, and snippets.

@ethanbergstrom
Last active December 2, 2023 14:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ethanbergstrom/9a4a0d29ea0452ef46bba580a7567d98 to your computer and use it in GitHub Desktop.
Save ethanbergstrom/9a4a0d29ea0452ef46bba580a7567d98 to your computer and use it in GitHub Desktop.
#region Local Configuration Manager
[DSCLocalConfigurationManager()]
configuration LCMConfig
{
Node localhost
{
Settings
{
ConfigurationMode = 'ApplyAndAutoCorrect'
# Check for updates once a day
ConfigurationModeFrequencyMins = 1440
}
}
}
LCMConfig
Set-DscLocalConfigurationManager .\LCMConfig\ -Verbose
Remove-Item .\LCMConfig\ -Force -Recurse
#endregion
#region Package Management
$cred = Get-Credential
$data = @{
AllNodes =
@(
@{
NodeName = 'localhost'
Packages = @(
'7zip.7zip',
'Balena.Etcher',
'CPUID.HWMonitor',
'dbeaver.dbeaver',
'Docker.DockerDesktop',
'Git.Git',
'Hashicorp.Vagrant',
'Microsoft.PowerShell',
'Microsoft.WindowsTerminal',
'Notepad++.Notepad++',
'Telerik.Fiddler.Classic',
'WinSCP.WinSCP'
)
# This is not secure! Encrypt DSC MOFs with certificates for secure usage.
PSDscAllowDomainUser = $true
PsDscAllowPlainTextPassword = $true
Credential = $cred
}
)
}
Configuration DevTools {
Import-DscResource -ModuleName PackageManagement -ModuleVersion 1.4.7
Node $AllNodes.NodeName {
PackageManagement WinGet {
Name = 'WinGet'
Source = 'PSGallery'
}
foreach ($package in $Node.Packages) {
PackageManagement $package {
Name = $package
ProviderName = 'WinGet'
RequiredVersion = 'latest'
DependsOn = @('[PackageManagement]WinGet')
# Required for the LCM to interact with your WinGet execution alias / source data
PsDscRunAsCredential = $Node.Credential
}
}
}
}
DevTools -ConfigurationData $data
Start-DscConfiguration .\DevTools -Force -Wait -Verbose
Remove-Item .\DevTools\ -Recurse -Force
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment