Skip to content

Commit

Permalink
Used Gael's code to add to ChocolateyPackages the ability to set Feat…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
kwein1 committed Jan 14, 2021
1 parent a16a862 commit d8f5586
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ configuration ChocolateyPackages {
[hashtable[]]$Sources,

[Parameter()]
[hashtable[]]$Packages
[hashtable[]]$Packages,

[Parameter()]
[hashtable[]]$Features
)

Import-DscResource -ModuleName PSDesiredStateConfiguration
Expand Down Expand Up @@ -218,22 +221,33 @@ configuration ChocolateyPackages {
TestScript = {
$val = Get-ItemProperty -Path $using:rebootKeyName -Name $using:rebootVarName -ErrorAction SilentlyContinue

if ($val -ne $null -and $val.$rebootVarName -gt 0) {
if ($val -ne $null -and $val.$rebootVarName -gt 0) {
return $true
}
}
return $false
}
SetScript = {
if( -not (Test-Path -Path $using:rebootKeyName) ) {
New-Item -Path $using:rebootKeyName -Force
}
Set-ItemProperty -Path $rebootKeyName -Name $using:rebootVarName -value 1
$global:DSCMachineStatus = 1
$global:DSCMachineStatus = 1
}
GetScript = { return @{result = 'result'}}
DependsOn = "[ChocolateyPackage]$executionName"
}
}
}
}
}

if( $Features -ne $null ) {
foreach ($f in $Features) {
$executionName = $f.Name -replace '\(|\)|\.| ', ''
$executionName = "ChocolateyFeature_$executionName"
if (-not $f.ContainsKey('Ensure')) {
$f.Ensure = 'Present'
}
(Get-DscSplattedResource -ResourceName ChocolateyFeature -ExecutionName $executionName -Properties $f -NoInvoke).Invoke($f)
}
}
}

0 comments on commit d8f5586

Please sign in to comment.