Skip to content

Instantly share code, notes, and snippets.

@hounsell
Created March 24, 2023 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hounsell/6ac3948d4a54d77d22a9b47e54ed2414 to your computer and use it in GitHub Desktop.
Save hounsell/6ac3948d4a54d77d22a9b47e54ed2414 to your computer and use it in GitHub Desktop.
Extract MemoryStream resources from a resx file (common in certain Longhorn-era components)
param([String] $resx_filename)
Add-Type -AssemblyName System.Windows.Forms
$resx = New-Object -TypeName 'System.Resources.ResXResourceSet' -ArgumentList $resx_filename
$root_path = [System.IO.Path]::GetDirectoryName($resx_filename);
foreach($item in $resx)
{
if ($item.Value.GetType() -Eq [System.IO.MemoryStream])
{
$out_path = [System.IO.Path]::Combine($root_path, $item.Name);
[System.IO.File]::WriteAllBytes($out_path, $item.Value.ToArray());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment