Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mgreenegit/891dddc6de8d7be5dfd2 to your computer and use it in GitHub Desktop.
Save mgreenegit/891dddc6de8d7be5dfd2 to your computer and use it in GitHub Desktop.
This is a quick script for POC labs, to grab the DSC Resource Kit (All Modules) file and populate them in to a DSC Pull Server
$AllModules = 'https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d/file/131371/1/DSC%20Resource%20Kit%20Wave%209%2012172014.zip'
$Folder = 'C:\AllModules'
$PullServerModules = 'C:\Program Files\WindowsPowerShell\DscService\Modules\'
if (!(Test-Path "$Folder\Archives")) {mkdir "$Folder\Archives" | out-null}
Invoke-WebRequest -Uri $AllModules -OutFile "$Folder\AllModules.zip"
Expand-Archive -Path "$Folder\AllModules.zip" -DestinationPath "$Folder\Extract" -Force
foreach ($ResourceFolder in (Get-ChildItem "$Folder\Extract\All Resources")) {
$ModuleData = Test-ModuleManifest "$($ResourceFolder.FullName)\$($ResourceFolder.Name).PSD1"
$File = "$($ModuleData.Name)_$($ModuleData.Version).zip"
Compress-Archive -Path $($ResourceFolder.FullName) -DestinationPath "$Folder\Archives\$File" -Force
}
New-DSCCheckSum -ConfigurationPath "$Folder\Archives" -OutPath "$Folder\Archives"
Copy-Item -Recurse "$Folder\Archives\*.*" $PullServerModules -Verbose
Remove-Item $Folder -Recurse -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment