Skip to content

Instantly share code, notes, and snippets.

@mwallner
Forked from JPRuskin/ARM.ps1
Created June 10, 2026 18:33
Show Gist options
  • Select an option

  • Save mwallner/62cb9258a73105e68ff3aa2f0073b734 to your computer and use it in GitHub Desktop.

Select an option

Save mwallner/62cb9258a73105e68ff3aa2f0073b734 to your computer and use it in GitHub Desktop.
Relatively untested extension to jankily add ARM support to the packaging functions.
function Get-OSArchitectureType {
param(
[ValidateSet('CISC', 'RISC')]
$Compare
)
$ArchType = if ($env:PROCESSOR_ARCHITECTURE.StartsWith('ARM')) {
'RISC'
} else {
'CISC'
}
if ($Compare) {
$ArchType -eq $Compare
} else {
$ArchType
}
}
function ShimArmFunctionality {
[CmdletBinding()]
param(
[string]$urlArm,
[alias("urlArm64")][string]$urlArm64bit,
[string]$checksumArm,
[string]$checksumArm64,
[string]$checksumTypeArm,
[string]$checksumTypeArm64
)
DynamicParam {
$paramDict = [System.Management.Automation.RuntimeDefinedParameterDictionary]::new()
[System.Management.Automation.CommandMetaData]::new((Get-Command (Get-PSCallStack)[0].InvocationInfo.InvocationName -Module chocolateyInstaller)).Parameters.GetEnumerator().ForEach{
$paramObject = [System.Management.Automation.RuntimeDefinedParameter]::new(
$_.Value.Name,
$_.Value.ParameterType,
$_.Value.Attributes
)
$paramDict.Add($_.Key, $paramObject)
}
return $paramDict
}
end {
$EventualProxiedArguments = $PSBoundParameters
if (Get-OSArchitectureType -Compare 'RISC') {
switch ($($PSBoundParameters.Keys)) {
"urlArm" {$EventualProxiedArguments.url = $urlArm}
"urlArm64" {$EventualProxiedArguments.url64bit = $urlArm64}
"checksumArm" {$EventualProxiedArguments.checksum = $checksumArm}
"checksumArm64" {$EventualProxiedArguments.checksum64 = $checksumArm64}
"checksumTypeArm" {$EventualProxiedArguments.checksumType = $checksumTypeArm}
"checksumTypeArm64" {$EventualProxiedArguments.checksumType64 = $checksumTypeArm64}
default {Write-Verbose "Nothing found for $_"}
}
}
# Remove any of the non-proxied parameters from the eventual call
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator().Where{
-not $_.Value.IsDynamic -and
$_.Key -notin [System.Management.Automation.PSCmdlet]::CommonParameters
}.ForEach{
Write-Verbose "Removing '$($_.Key)' from the passed parameters"
$null = $EventualProxiedArguments.Remove($_.Key)
}
# $EventualProxiedArguments | ConvertTo-Json | Write-Output | Write-Debug
& $($MyInvocation.InvocationName) @EventualProxiedArguments
}
}
# if (-not (Get-Module chocolateyInstaller)) {
# Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
# }
Get-Command -Module chocolateyInstaller -ParameterName Url64 <#,File64#> | ForEach-Object {
if ($_.Parameters.Keys -notcontains 'UrlArm') {
Set-Alias -Scope Global -Name $_.Name -Value ShimArmFunctionality
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment