Skip to content

Instantly share code, notes, and snippets.

@FrankSpierings
Last active September 6, 2021 14:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save FrankSpierings/cbf9e86c3055dea3477e393742a0dedc to your computer and use it in GitHub Desktop.
Save FrankSpierings/cbf9e86c3055dea3477e393742a0dedc to your computer and use it in GitHub Desktop.
Read file, gzip and convert to base64.
$filepath = "/etc/passwd"
$fs = New-Object IO.FileStream($filepath, [System.IO.FileMode]::Open)
$ms = New-Object System.IO.MemoryStream;
$gzs = New-Object System.IO.Compression.GzipStream($ms, [System.IO.Compression.CompressionMode]::Compress);
$fs.CopyTo($gzs);
$fs.Close();
$gzs.Close();
$ms.Close();
[System.Convert]::ToBase64String($ms.ToArray());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment