Last active
September 7, 2016 01:06
-
-
Save ephos/806e1979259348b8526b5fa6c40503ba to your computer and use it in GitHub Desktop.
DSC Composite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-Item 'C:\Program Files\WindowsPowerShell\Modules\' -ItemType Directory -Name TestModule | |
New-Item 'C:\Program Files\WindowsPowerShell\Modules\TestModule\DSCResources\' -ItemType Directory -Name CompRes1 | |
New-Item 'C:\Program Files\WindowsPowerShell\Modules\TestModule\DSCResources\' -ItemType Directory -Name CompRes2 | |
New-Item 'C:\Program Files\WindowsPowerShell\Modules\TestModule\DSCResources\CompRes1\' -ItemType File -Name CompRes1.psd1 -Value "'RootModule = CompRes1.schema.psm1'" | |
New-Item 'C:\Program Files\WindowsPowerShell\Modules\TestModule\DSCResources\CompRes2\' -ItemType File -Name CompRes2.psd1 -Value "'RootModule = CompRes2.schema.psm1'" | |
New-ModuleManifest -Path 'C:\Program Files\WindowsPowerShell\Modules\TestModule\TestModule.psd1' -DscResourcesToExport Compres1,CompRes2 | |
$contentsCompRes1 = @' | |
configuration CompRes1 | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$PackagePath, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$PackageSource, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[System.Management.Automation.PSCredential] | |
[System.Management.Automation.CredentialAttribute()] | |
$Credential | |
) | |
<# | |
Contains installations and packages that need to be applied globally to all systems. | |
#> | |
Import-DscResource -ModuleName xPSDesiredStateConfiguration | |
File PackageZipCopy | |
{ | |
Ensure = 'Present' | |
DestinationPath = 'C:\Package' | |
Credential = $Credential | |
Force = $true | |
MatchSource = $true | |
Recurse = $true | |
SourcePath = $PackageSource | |
Type = 'File' | |
} | |
xArchive PackageUnzip | |
{ | |
Path = 'C:\Package.zip' | |
Ensure = 'Present' | |
Destination = 'C:\Package\' | |
Force = $true | |
DependsOn = '[File]PackageZipCopy' | |
} | |
xPackage Package1 | |
{ | |
Ensure = 'Present' | |
Name = 'Test' | |
Path = ($PackagePath + 'Test.exe') | |
DependsOn = '[xArchive]PackageUnzip' | |
} | |
File PackageCleanup | |
{ | |
Ensure = 'Absent' | |
Recurse = $true | |
Force = $true | |
DestinationPath = 'C:\Package\' | |
Type = 'Directory' | |
DependsOn = @('[xPackage]Package1') | |
} | |
} | |
'@ | |
$contentsCompRes2 = @' | |
configuration CompRes2 | |
{ | |
param | |
( | |
) | |
<# | |
Contains registry settings that need to be applied globally to all systems. | |
#> | |
Import-DscResource -ModuleName xPSDesiredStateConfiguration | |
xRegistry TestReg | |
{ | |
Ensure = 'Present' | |
Key = 'HKEY_LOCAL_MACHINE\SYSTEM\FakeTest' | |
ValueName = 'NotReal' | |
ValueType = 'Dword' | |
ValueData = '1' | |
Force = $true | |
} | |
} | |
'@ | |
New-Item 'C:\Program Files\WindowsPowerShell\Modules\TestModule\DSCResources\CompRes1\' -ItemType File -Name CompRes1.schema.psm1 -Value $contentsCompRes1 | |
New-Item 'C:\Program Files\WindowsPowerShell\Modules\TestModule\DSCResources\CompRes2\' -ItemType File -Name CompRes2.schema.psm1 -Value $contentsCompRes2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment