Skip to content

Instantly share code, notes, and snippets.

@jamesallen-cm
Last active August 29, 2015 14:23
Show Gist options
  • Save jamesallen-cm/7ac731e89c45b921106b to your computer and use it in GitHub Desktop.
Save jamesallen-cm/7ac731e89c45b921106b to your computer and use it in GitHub Desktop.
Run this on your DSC server to setup and config a http server. It will install WMF 5.0, download the latest DSC packages, zip them up, and create the checksums.
$Boxstarter.RebootOk=$true
# enable psremoting
Write-Output "Enabling PSRemoting"
Enable-PSRemoting -Force
if($PSVersionTable.PSVersion -lt (New-Object 'Version' 5,0,10018,0))
{
# install WMF5.0 February and April
cinst powershell -version 5.0.10018-February2015Preview -pre -y
# Write-Output "Installing the April 2015 Powershell DSC preview"
# cinst powershell -pre -y
Write-Output "Restarting to complete installation"
Invoke-Reboot
}
else
{
Write-output "Load nuget-anycpu.exe"
Get-PackageProvider -Name NuGet -ForceBootstrap
}
# Install the latest DSC modules
Write-Output "Install the latest DSC Resources from Powershell Gallery"
Find-DscResource | Where{$_.Name -like "x*" -or $_.Name -like "c*"} | Install-Module -Force
# Zip up the files and create checksums
Write-Output "Zip up the resources and create a checksum for each - Required for the pull server to send configs to a node"
$dscResources = "$env:ProgramFiles\WindowsPowerShell\Modules\"
$baseDestination = "$env:ProgramFiles\WindowsPowerShell\DscService\Modules\"
$versions = Get-ChildItem $dscResources -Recurse -Directory | Where{$_.BaseName -match "^\d\."} | Select-Object -Property Parent,BaseName,FullName
$versions | ForEach-Object -Process `
{
$zipModuleName = "$($_.Parent)" + "_" + "$($_.BaseName)" + ".zip"
$zipDestination = $baseDestination + $zipModuleName
$path = "$($_.FullName)\*"
Compress-Archive -Path $path -DestinationPath $zipDestination
}
# We need to zip up the installed version of PSDesiredStateConfiguration and put it in modules
$PSDSCModule = Get-Module PSDesiredStateConfiguration
$zipPSDSCModule = $PSDSCModule.Name + "_" + $PSDSCModule.Version + ".zip"
$zipDestination = $baseDestination + $zipPSDSCModule
Compress-Archive -Path $($PSDSCModule.Path) -DestinationPath $zipDestination
# create the checksums for the pull modules
New-DscChecksum -ConfigurationPath $baseDestination
# Configure the DSCPullServer using the xPSDesiredStateConfiguration module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment