en-US/PSCompression-help.xml
<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml" xmlns="http://msh"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Compress-GzipArchive</command:name> <command:verb>Compress</command:verb> <command:noun>GzipArchive</command:noun> <maml:description> <maml:para>Creates a Gzip compressed file from specified File Paths or input Bytes.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Compress-GzipArchive` cmdlet can compress one or more specified file paths into a single Gzip archive using the `GzipStream` Class (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream). For expansion see [`Expand-GzipArchive`](Expand-ZipEntry.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Compress-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The path where to store the Gzip compressed file. The parent directory is created if it does not exist.</maml:para> <maml:para>> NOTE: If the path does not end with `.gz`, the cmdlet appends the `.gz` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Define the compression level that should be used. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the Gzip archive if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description> <maml:para>This cmdlet can take input bytes from pipeline to create the output `.gz` archive file.</maml:para> <maml:para>> NOTE: This parameter is meant to be used exclusively in combination with `ConvertTo-GzipString -AsByteStream`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Byte[]</command:parameterValue> <dev:type> <maml:name>Byte[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Appends content to the existing Gzip file if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Compress-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The path where to store the Gzip compressed file. The parent directory is created if it does not exist.</maml:para> <maml:para>> NOTE: If the path does not end with `.gz`, the cmdlet appends the `.gz` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Define the compression level that should be used. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the Gzip archive if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the Gzip archive file. Unlike the `-Path` Parameter, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Appends content to the existing Gzip file if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Compress-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the Gzip archive file. To specify multiple paths, and include files in multiple locations, use commas to separate the paths. This Parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The path where to store the Gzip compressed file. The parent directory is created if it does not exist.</maml:para> <maml:para>> NOTE: If the path does not end with `.gz`, the cmdlet appends the `.gz` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Define the compression level that should be used. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the Gzip archive if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Appends content to the existing Gzip file if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Define the compression level that should be used. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The path where to store the Gzip compressed file. The parent directory is created if it does not exist.</maml:para> <maml:para>> NOTE: If the path does not end with `.gz`, the cmdlet appends the `.gz` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the Gzip archive if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="named" aliases="none"> <maml:name>InputBytes</maml:name> <maml:description> <maml:para>This cmdlet can take input bytes from pipeline to create the output `.gz` archive file.</maml:para> <maml:para>> NOTE: This parameter is meant to be used exclusively in combination with `ConvertTo-GzipString -AsByteStream`.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Byte[]</command:parameterValue> <dev:type> <maml:name>Byte[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the Gzip archive file. Unlike the `-Path` Parameter, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the Gzip archive file. To specify multiple paths, and include files in multiple locations, use commas to separate the paths. This Parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Appends content to the existing Gzip file if exists, otherwise it creates it.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe paths to this cmdlet. Output from `Get-ChildItem` or `Get-Item` can be piped to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>By default, this cmdlet produces no output.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>FileInfo</maml:name> </dev:type> <maml:description> <maml:para>When the `-PassThru` switch is used this cmdlet outputs the `FileInfo` instance representing the compressed file.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert /> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Create a Gzip compressed file from a File Path --</maml:title> <dev:code>PS ..\pwsh> Compress-GzipArchive path\to\myFile.ext -Destination myFile.gz</dev:code> <dev:remarks> <maml:para>If the destination does not end with `.gz` the extension is automatically added.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 2: Create a Gzip compressed file from a string ----</maml:title> <dev:code>PS ..\pwsh> 'hello world!' | ConvertTo-GzipString -AsByteStream | Compress-GzipArchive -Destination .\files\file.gz</dev:code> <dev:remarks> <maml:para>Demonstrates how `-AsByteStream` works on `ConvertTo-GzipString`. Sends the compressed bytes to `Compress-GzipArchive`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 3: Append content to a Gzip archive ---------</maml:title> <dev:code>PS ..\pwsh> 'this is new content...' | ConvertTo-GzipString -AsByteStream | Compress-GzipArchive -Destination .\files\file.gz -Update</dev:code> <dev:remarks> <maml:para>Demonstrates how `-Update` works.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 4: Replace a Gzip archive with new content ------</maml:title> <dev:code>PS ..\pwsh> $lorem = Invoke-RestMethod loripsum.net/api/10/long/plaintext PS ..\pwsh> $lorem | ConvertTo-GzipString -AsByteStream | Compress-GzipArchive -Destination .\files\file.gz -Force</dev:code> <dev:remarks> <maml:para>Demonstrates how `-Force` works.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>- Example 5: Compressing multiple files into one Gzip archive -</maml:title> <dev:code>PS ..\pwsh> 0..10 | ForEach-Object { Invoke-RestMethod loripsum.net/api/10/long/plaintext -OutFile .\files\lorem$_.txt } # Check the total Length of the downloaded files PS ..\pwsh> (Get-Content .\files\lorem*.txt | Measure-Object Length -Sum).Sum / 1kb 86.787109375 # Check the total Length after compression PS ..\pwsh> (Compress-GzipArchive .\files\lorem*.txt -Destination .\files\mergedLorem.gz -PassThru).Length / 1kb 27.6982421875</dev:code> <dev:remarks> <maml:para>Due to the nature of Gzip without Tar, all file contents are merged into a single file.</maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://github.com/santisq/PSCompression</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Compress-ZipArchive</command:name> <command:verb>Compress</command:verb> <command:noun>ZipArchive</command:noun> <maml:description> <maml:para>The `Compress-ZipArchive` cmdlet creates a compressed, or zipped, archive file from one or more specified files or directories. It aims to overcome a few limitations of `Compress-Archive` (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.2)while keeping similar pipeline capabilities.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>PowerShell cmdlet that overcomes the limitation that the built-in cmdlet `Compress-Archive` has:</maml:para> <maml:para>> The `Compress-Archive` cmdlet uses the Microsoft .NET API `System.IO.Compression.ZipArchive` (https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchive?view=net-6.0)to compress files. The maximum file size is 2 GB because there's a limitation of the underlying API.</maml:para> <maml:para>The easy workaround would be to use the `ZipFile.CreateFromDirectory` Method (https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.createfromdirectory?view=net-6.0#system-io-compression-zipfile-createfromdirectory(system-string-system-string)). However, there are 3 limitations while using this static method:</maml:para> <maml:para> 1. The source must be a directory , a single file cannot be compressed. 2. All files (recursively) on the source folder will be compressed , we can't pick / filter files to compress. 3. It's not possible to Update the entries of an existing Zip Archive.</maml:para> <maml:para>This function should be able to handle compression same as `ZipFile.CreateFromDirectory` Method but also allow filtering files and folders to compress while keeping the file / folder structure untouched .</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Compress-ZipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the archive zipped file. To specify multiple paths, and include files in multiple locations, use commas to separate the paths.</maml:para> <maml:para>This parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> <maml:para>Using wildcards with a root directory affects the archive's contents:</maml:para> <maml:para> - To create an archive that includes the root directory, and all its files and subdirectories, specify the root directory in the Path without wildcards. For example: `-Path C:\Reference` - To create an archive that excludes the root directory, but zips all its files and subdirectories, use the asterisk (` `) wildcard. For example: `-Path C:\Reference\ ` - To create an archive that only zips the files in the root directory, use the star-dot-star (` . `) wildcard. Subdirectories of the root aren't included in the archive. For example: `-Path C:\Reference\ . `</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>This parameter is required and specifies the path to the archive output file. The DestinationPath should include the name of the zipped file, and either the absolute or relative path to the zipped file.</maml:para> <maml:para>If the file name in DestinationPath doesn't have a `.zip` file name extension, the cmdlet adds the `.zip` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Specifies values that indicate whether a compression operation emphasizes speed or compression size. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Updates the specified archive by replacing older file versions in the archive with newer file versions that have the same names. You can also add this parameter to add files to an existing archive.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Compress-ZipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>This parameter is required and specifies the path to the archive output file. The DestinationPath should include the name of the zipped file, and either the absolute or relative path to the zipped file.</maml:para> <maml:para>If the file name in DestinationPath doesn't have a `.zip` file name extension, the cmdlet adds the `.zip` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the archive zipped file. Unlike the Path `-Parameter`, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Specifies values that indicate whether a compression operation emphasizes speed or compression size. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Updates the specified archive by replacing older file versions in the archive with newer file versions that have the same names. You can also add this parameter to add files to an existing archive.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Compress-ZipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>This parameter is required and specifies the path to the archive output file. The DestinationPath should include the name of the zipped file, and either the absolute or relative path to the zipped file.</maml:para> <maml:para>If the file name in DestinationPath doesn't have a `.zip` file name extension, the cmdlet adds the `.zip` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Specifies values that indicate whether a compression operation emphasizes speed or compression size. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Updates the specified archive by replacing older file versions in the archive with newer file versions that have the same names. You can also add this parameter to add files to an existing archive.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the destination archive if exists otherwise it creates a new one. All Zip entries are lost.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Compress-ZipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>This parameter is required and specifies the path to the archive output file. The DestinationPath should include the name of the zipped file, and either the absolute or relative path to the zipped file.</maml:para> <maml:para>If the file name in DestinationPath doesn't have a `.zip` file name extension, the cmdlet adds the `.zip` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Specifies values that indicate whether a compression operation emphasizes speed or compression size. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Updates the specified archive by replacing older file versions in the archive with newer file versions that have the same names. You can also add this parameter to add files to an existing archive.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the destination archive if exists otherwise it creates a new one. All Zip entries are lost.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="true" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the archive zipped file. To specify multiple paths, and include files in multiple locations, use commas to separate the paths.</maml:para> <maml:para>This parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> <maml:para>Using wildcards with a root directory affects the archive's contents:</maml:para> <maml:para> - To create an archive that includes the root directory, and all its files and subdirectories, specify the root directory in the Path without wildcards. For example: `-Path C:\Reference` - To create an archive that excludes the root directory, but zips all its files and subdirectories, use the asterisk (` `) wildcard. For example: `-Path C:\Reference\ ` - To create an archive that only zips the files in the root directory, use the star-dot-star (` . `) wildcard. Subdirectories of the root aren't included in the archive. For example: `-Path C:\Reference\ . `</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the files that you want to add to the archive zipped file. Unlike the Path `-Parameter`, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>This parameter is required and specifies the path to the archive output file. The DestinationPath should include the name of the zipped file, and either the absolute or relative path to the zipped file.</maml:para> <maml:para>If the file name in DestinationPath doesn't have a `.zip` file name extension, the cmdlet adds the `.zip` file name extension.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Specifies values that indicate whether a compression operation emphasizes speed or compression size. See `CompressionLevel` Enum (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel)for details.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Updates the specified archive by replacing older file versions in the archive with newer file versions that have the same names. You can also add this parameter to add files to an existing archive.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>Overwrites the destination archive if exists otherwise it creates a new one. All Zip entries are lost.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will add or update entries.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the compressed file. The cmdlet produces no output by default.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe a string that contains a path to one or more files. Output from `Get-ChildItem` or `Get-Item` can be piped to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>By default, this cmdlet produces no output.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>FileInfo</maml:name> </dev:type> <maml:description> <maml:para>When the `-PassThru` switch is used this cmdlet outputs the `FileInfo` instance representing the compressed file.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>This function was initially posted to address this Stack Overflow question (https://stackoverflow.com/a/72611161/15339544). [Another question](https://stackoverflow.com/q/74129754/15339544) in the same site pointed out another limitation with the native cmdlet, it can't compress if another process has a handle on a file. To overcome this issue, and also to emulate explorer's behavior when compressing files used by another process, the function posted below will default to __[`[FileShare] 'ReadWrite, Delete'`](https://learn.microsoft.com/en-us/dotnet/api/system.io.fileshare?view=net-6.0)__ when opening a [`FileStream`](https://learn.microsoft.com/en-us/dotnet/api/system.io.file.open?view=net-7.0).</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>- Example 1: Compress all `.ext` files from a specific folder -</maml:title> <dev:code>Get-ChildItem .\path -Recurse -Filter *.ext | Compress-ZipArchive -DestinationPath dest.zip</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 2: Compress all `.txt` files contained in all folders in the Current Directory</maml:title> <dev:code>Compress-ZipArchive .\*\*.txt -DestinationPath dest.zip</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 3: Compress all `.ext` and `.ext2` from a specific folder</maml:title> <dev:code>Compress-ZipArchive .\*.ext, .\*.ext2 -DestinationPath dest.zip</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Compress a folder using `Fastest` Compression Level</maml:title> <dev:code>Compress-ZipArchive .\path -Destination myPath.zip -CompressionLevel Fastest</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 5: Compressing all directories in `.\Path` ------</maml:title> <dev:code>Get-ChildItem .\path -Recurse -Directory | Compress-ZipArchive -DestinationPath dest.zip</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>--------- Example 6: Replacing an existing Zip Archive ---------</maml:title> <dev:code>Compress-ZipArchive -Path .\path -DestinationPath dest.zip -Force</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 7: Adding and updating new entries to an existing Zip Archive</maml:title> <dev:code>Get-ChildItem .\path -Recurse -Directory | Compress-ZipArchive -DestinationPath dest.zip -Update</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://github.com/santisq/PSCompression</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertFrom-GzipString</command:name> <command:verb>ConvertFrom</command:verb> <command:noun>GzipString</command:noun> <maml:description> <maml:para>Expands Base64 Gzip compressed input strings.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertFrom-GzipString` cmdlet can expand Base64 encoded Gzip compressed strings using the `GzipStream` Class (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream). This cmdlet is the counterpart of [`ConvertTo-GzipString`](ConvertTo-GzipString.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-GzipString</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies the input string or strings to expand.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Determines the character encoding used when expanding the input strings. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Utf8</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Raw</maml:name> <maml:description> <maml:para>Outputs the expanded string as a single string with newlines preserved. By default, newline characters in the expanded string are used as delimiters to separate the input into an array of strings.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Determines the character encoding used when expanding the input strings. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Utf8</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies the input string or strings to expand.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Raw</maml:name> <maml:description> <maml:para>Outputs the expanded string as a single string with newlines preserved. By default, newline characters in the expanded string are used as delimiters to separate the input into an array of strings.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe Gzip Base64 strings to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>By default, this cmdlet streams strings. When the `-Raw` switch is used, it returns a single multi-line string.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert /> </maml:alertSet> <command:examples> <command:example> <maml:title>-------- Example 1: Expanding a Gzip compressed string --------</maml:title> <dev:code>PS ..\pwsh> ConvertFrom-GzipString H4sIAAAAAAAACstIzcnJ5+Uqzy/KSeHlUuTlAgBLr/K2EQAAAA== hello world !</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>-------- Example 2: Demonstrates how `-NoNewLine` works --------</maml:title> <dev:code>PS ..\pwsh> $strings = 'hello', 'world', '!' # New lines are preserved when the cmdlet receives an array of strings. PS ..\pwsh> $strings | ConvertTo-GzipString | ConvertFrom-GzipString hello world ! # When using the `-NoNewLine` switch, all strings are concatenated PS ..\pwsh> $strings | ConvertTo-GzipString -NoNewLine | ConvertFrom-GzipString helloworld!</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://github.com/santisq/PSCompression</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>ConvertTo-GzipString</command:name> <command:verb>ConvertTo</command:verb> <command:noun>GzipString</command:noun> <maml:description> <maml:para>Creates a Gzip Base64 compressed string from a specified input string or strings.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `ConvertTo-GzipString` cmdlet can compress input strings into Gzip Base64 encoded strings or raw bytes using the `GzipStream` Class (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream). For expansion of Base64 Gzip strings, see [`ConvertFrom-GzipString`](ConvertFrom-GzipString.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-GzipString</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies the input string or strings to compress.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Raw"> <maml:name>AsByteStream</maml:name> <maml:description> <maml:para>Outputs the compressed byte array to the Success Stream.</maml:para> <maml:para>> NOTE: This parameter is meant to be used in combination with `Compress-GzipArchive`.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Define the compression level that should be used. See [`CompressionLevel` Enum](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel) for details .</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" command:variableLength="false">Optimal</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">Fastest</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">NoCompression</command:parameterValue> <command:parameterValue required="false" command:variableLength="false">SmallestSize</command:parameterValue> </command:parameterValueGroup> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Determines the character encoding used when compressing the input strings. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Utf8</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewLine</maml:name> <maml:description> <maml:para>The encoded string representation of the input objects are concatenated to form the output. No new line character is added after each output string when this switch is used.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="Raw"> <maml:name>AsByteStream</maml:name> <maml:description> <maml:para>Outputs the compressed byte array to the Success Stream.</maml:para> <maml:para>> NOTE: This parameter is meant to be used in combination with `Compress-GzipArchive`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>CompressionLevel</maml:name> <maml:description> <maml:para>Define the compression level that should be used. See [`CompressionLevel` Enum](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel) for details .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">CompressionLevel</command:parameterValue> <dev:type> <maml:name>CompressionLevel</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Optimal</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Determines the character encoding used when compressing the input strings. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>Utf8</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>InputObject</maml:name> <maml:description> <maml:para>Specifies the input string or strings to compress.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>NoNewLine</maml:name> <maml:description> <maml:para>The encoded string representation of the input objects are concatenated to form the output. No new line character is added after each output string when this switch is used.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe strings to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>By default, this cmdlet outputs a single string.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>Byte[]</maml:name> </dev:type> <maml:description> <maml:para>When the `-AsByteStream` switch is used this cmdlet outputs a byte array down the pipeline.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert /> </maml:alertSet> <command:examples> <command:example> <maml:title>Example 1: Compress strings to Gzip compressed Base64 encoded string</maml:title> <dev:code>PS ..\pwsh> $strings = 'hello', 'world', '!' # With positional binding PS ..\pwsh> ConvertTo-GzipString $strings H4sIAAAAAAAEAMtIzcnJ5+Uqzy/KSeHlUuTlAgBLr/K2EQAAAA== # Or pipeline input, both work PS ..\pwsh> $strings | ConvertTo-GzipString H4sIAAAAAAAEAMtIzcnJ5+Uqzy/KSeHlUuTlAgBLr/K2EQAAAA==</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 2: Create a Gzip compressed file from a string ----</maml:title> <dev:code>PS ..\pwsh> 'hello world!' | ConvertTo-GzipString -AsByteStream | Compress-GzipArchive -DestinationPath .\files\file.gz</dev:code> <dev:remarks> <maml:para>Demonstrates how `-AsByteStream` works on `ConvertTo-GzipString`, the cmdlet outputs a byte array that is received by `Compress-GzipArchive` and stored in a file. Note that the byte array is not enumerated .</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---- Example 3: Compress strings using a specific Encoding ----</maml:title> <dev:code>PS ..\pwsh> 'ñ' | ConvertTo-GzipString -Encoding ansi | ConvertFrom-GzipString � PS ..\pwsh> 'ñ' | ConvertTo-GzipString -Encoding utf8BOM | ConvertFrom-GzipString ñ</dev:code> <dev:remarks> <maml:para>The default Encoding is `utf8NoBom`.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Compressing multiple files into one Gzip Base64 string</maml:title> <dev:code>PS ..\pwsh> 0..10 | ForEach-Object { Invoke-RestMethod loripsum.net/api/10/long/plaintext -OutFile .\files\lorem$_.txt } # Check the total Length of the downloaded files PS ..\pwsh> (Get-Content .\files\lorem*.txt | Measure-Object Length -Sum).Sum / 1kb 87.216796875 # Check the total Length after compression PS ..\pwsh> (Get-Content .\files\lorem*.txt | ConvertTo-GzipString).Length / 1kb 36.94921875</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://github.com/santisq/PSCompression</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Expand-GzipArchive</command:name> <command:verb>Expand</command:verb> <command:noun>GzipArchive</command:noun> <maml:description> <maml:para>Expands a Gzip compressed file from a specified File Path or Paths.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>The `Expand-GzipArchive` cmdlet aims to expand Gzip compressed files to a destination path or to the success stream using the `GzipStream` Class (https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream). This cmdlet is the counterpart of [`Compress-GzipArchive`](Compress-GzipArchive.md).</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Expand-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the Gzip files to expand. To specify multiple paths, and include files in multiple locations, use commas to separate the paths. This Parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The destination path where to expand the Gzip file. The target folder is created if it does not exist.</maml:para> <maml:para>> NOTE: This parameter is Optional, if not used, this cmdlet outputs to the Success Stream.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the expanded file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>The destination file gets overwritten if exists, otherwise created when this switch is used.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Contents of the expanded file or files are appended to the destination path if exists, otherwise the destination is created.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Expand-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the Gzip files to expand. To specify multiple paths, and include files in multiple locations, use commas to separate the paths. This Parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Character encoding used when expanding the Gzip content. This parameter is only available when expanding to the Success Stream. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>utf8NoBOM</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Raw</maml:name> <maml:description> <maml:para>Outputs the expanded file as a single string with newlines preserved. By default, newline characters in the expanded string are used as delimiters to separate the input into an array of strings.</maml:para> <maml:para>> NOTE: This parameter is only available when expanding to the Success Stream.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Expand-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the Gzip files to expand. Unlike the `-Path` Parameter, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The destination path where to expand the Gzip file. The target folder is created if it does not exist.</maml:para> <maml:para>> NOTE: This parameter is Optional, if not used, this cmdlet outputs to the Success Stream.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the expanded file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>The destination file gets overwritten if exists, otherwise created when this switch is used.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Contents of the expanded file or files are appended to the destination path if exists, otherwise the destination is created.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Expand-GzipArchive</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the Gzip files to expand. Unlike the `-Path` Parameter, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Character encoding used when expanding the Gzip content. This parameter is only available when expanding to the Success Stream. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>utf8NoBOM</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Raw</maml:name> <maml:description> <maml:para>Outputs the expanded file as a single string with newlines preserved. By default, newline characters in the expanded string are used as delimiters to separate the input into an array of strings.</maml:para> <maml:para>> NOTE: This parameter is only available when expanding to the Success Stream.</maml:para> </maml:description> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="none"> <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path or paths to the Gzip files to expand. To specify multiple paths, and include files in multiple locations, use commas to separate the paths. This Parameter accepts wildcard characters. Wildcard characters allow you to add all files in a directory to your archive file.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="PSPath"> <maml:name>LiteralPath</maml:name> <maml:description> <maml:para>Specifies the path or paths to the Gzip files to expand. Unlike the `-Path` Parameter, the value of `-LiteralPath` is used exactly as it's typed. No characters are interpreted as wildcards</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String[]</command:parameterValue> <dev:type> <maml:name>String[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="DestinationPath"> <maml:name>Destination</maml:name> <maml:description> <maml:para>The destination path where to expand the Gzip file. The target folder is created if it does not exist.</maml:para> <maml:para>> NOTE: This parameter is Optional, if not used, this cmdlet outputs to the Success Stream.</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">String</command:parameterValue> <dev:type> <maml:name>String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Encoding</maml:name> <maml:description> <maml:para>Character encoding used when expanding the Gzip content. This parameter is only available when expanding to the Success Stream. The default encoding is `utf8NoBOM` .</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">Encoding</command:parameterValue> <dev:type> <maml:name>Encoding</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>utf8NoBOM</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Raw</maml:name> <maml:description> <maml:para>Outputs the expanded file as a single string with newlines preserved. By default, newline characters in the expanded string are used as delimiters to separate the input into an array of strings.</maml:para> <maml:para>> NOTE: This parameter is only available when expanding to the Success Stream.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>Outputs the object representing the expanded file.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Force</maml:name> <maml:description> <maml:para>The destination file gets overwritten if exists, otherwise created when this switch is used.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"> <maml:name>Update</maml:name> <maml:description> <maml:para>Contents of the expanded file or files are appended to the destination path if exists, otherwise the destination is created.</maml:para> <maml:para>> NOTE: If `-Force` and `-Update` are used together this cmdlet will append content to the destination file.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>You can pipe paths to this cmdlet. Output from `Get-ChildItem` or `Get-Item` can be piped to this cmdlet.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>String</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet outputs an array of string to the success stream when `-Destination` is not used and a single multi-line string when used with the `-Raw` switch.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>None</maml:name> </dev:type> <maml:description> <maml:para>This cmdlet produces no output when expanding to a file and `-PassThru` is not used.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>FileInfo</maml:name> </dev:type> <maml:description> <maml:para>When the `-PassThru` switch is used this cmdlet outputs the `FileInfo` instance representing the expanded file.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert /> </maml:alertSet> <command:examples> <command:example> <maml:title>-- Example 1: Expanding a Gzip archive to the success stream --</maml:title> <dev:code>PS ..\pwsh> Expand-GzipArchive .\files\file.gz hello world!</dev:code> <dev:remarks> <maml:para>Output goes to the Success Stream when `-Destination` is not used.</maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------ Example 2: Expanding a Gzip archive to a new file ------</maml:title> <dev:code>PS ..\pwsh> Expand-GzipArchive .\files\file.gz -Destination .\files\file.txt # Checking Length Difference PS ..\pwsh> Get-Item -Path .\files\file.gz, .\files\file.txt | Select-Object Name, Length Name Length ---- ------ file.gz 3168 file.txt 6857</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>------- Example 3: Appending content to an existing file -------</maml:title> <dev:code>PS ..\pwsh> Expand-GzipArchive *.gz -Destination .\files\file.txt -Update</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>Example 4: Expanding a Gzip archive overwritting an existing file</maml:title> <dev:code>PS ..\pwsh> Expand-GzipArchive *.gz -Destination .\files\file.txt -Force</dev:code> <dev:remarks> <maml:para></maml:para> </dev:remarks> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version:</maml:linkText> <maml:uri>https://github.com/santisq/PSCompression</maml:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems> |