localscript/Invoke-GenerateCmdlet.ps1
function Invoke-GenerateCmdlet { param( $Path ) $SetFunction = @" function Set-{FUNCTION} { <# .SYNOPSIS Enables or disables the {DISPLAYNAME} setting .DESCRIPTION The Set-{FUNCTION} cmdlet is used to enable or disable the {DISPLAYNAME} setting .NOTES Written by Jaap Brasser for community usage Twitter: @jaap_brasser GitHub: jaapbrasser .LINK TBD .EXAMPLE Set-{FUNCTION} -Enable Enables the {DISPLAYNAME} setting .EXAMPLE Set-{FUNCTION} -Disable -Verbose Disables the {DISPLAYNAME} setting, while displaying verbose information #> [CmdletBinding(SupportsShouldProcess = `$true)] Param( [Parameter(Mandatory = `$true, ParameterSetName='Enable', HelpMessage = 'Enable {DISPLAYNAME}')] [switch] `$Enable, [Parameter(Mandatory = `$true, ParameterSetName='Disable', HelpMessage = 'Disable {DISPLAYNAME}')] [switch] `$Disable ) Invoke-ConfigurationData -CallingCmdlet `$MyInvocation.MyCommand.Name -Parameter `$PSBoundParameters } "@ $GetFunction = @" function Get-{FUNCTION} { <# .SYNOPSIS Queries the current setting of {DISPLAYNAME} .DESCRIPTION The Get-{FUNCTION} cmdlet is used to query the current setting of {DISPLAYNAME} .NOTES Written by Jaap Brasser for community usage Twitter: @jaap_brasser GitHub: jaapbrasser .LINK TBD .EXAMPLE Get-{FUNCTION} Verifies whether {DISPLAYNAME} is enabled or disabled .EXAMPLE Get-{FUNCTION} -Verbose Verifies whether {DISPLAYNAME} is enabled or disabled, while displaying verbose information #> [CmdletBinding(SupportsShouldProcess = `$true)] Param( ) Invoke-ConfigurationData -CallingCmdlet `$MyInvocation.MyCommand.Name -Parameter `$PSBoundParameters } "@ $Json = Get-Content -Path $Path -Raw | ConvertFrom-Json $Function = (Get-Item $Path).BaseName $DisplayName = $Function -creplace '(?<!^)([A-Z])',' $1' $SetFunction -replace '{FUNCTION}',$Function -replace '{DISPLAYNAME}',$DisplayName | Out-File -Encoding utf8 -FilePath "C:\temp\CustomizeWindows11\public\Set-$Function.ps1" -NoNewline $GetFunction -replace '{FUNCTION}',$Function -replace '{DISPLAYNAME}',$DisplayName | Out-File -Encoding utf8 -FilePath "C:\temp\CustomizeWindows11\public\Get-$Function.ps1" -NoNewline } Get-ChildItem './private/data' | % {Invoke-GenerateCmdlet -Path $_.FullName} Get-Item './private/data/TaskbarShowClock.json' | % {Invoke-GenerateCmdlet -Path $_.FullName} Get-Item './private/data/TaskbarAdditionalCalendar.json' | % {Invoke-GenerateCmdlet -Path $_.FullName} |