Created
November 5, 2017 22:32
-
-
Save gaelcolas/96ff332c59a38e682cc7cc3aea730f72 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function Get-DscSplattedResource { | |
[CmdletBinding()] | |
Param( | |
[String] | |
$ResourceName, | |
[String] | |
$ExecutionName, | |
[hashtable] | |
$Properties | |
) | |
$stringBuilder = [System.Text.StringBuilder]::new() | |
$null = $stringBuilder.AppendLine("Param([hashtable]`$Parameters)") | |
$null = $stringBuilder.AppendLine(" $ResourceName $ExecutionName { ") | |
foreach($PropertyName in $Properties.keys) { | |
$null = $stringBuilder.AppendLine("$PropertyName = `$(`$Parameters['$PropertyName'])") | |
} | |
$null = $stringBuilder.AppendLine("}") | |
Write-Debug ("Generated Resource Block = {0}" -f $stringBuilder.ToString()) | |
[scriptblock]::Create($stringBuilder.ToString()).Invoke($Properties) | |
} | |
Set-Alias -Name x -Value Get-DscSplattedResource |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
``