external help file | Module Name | online version | schema |
---|---|---|---|
PSCompression.dll-Help.xml |
PSCompression |
2.0.0 |
Sets or appends content to an existing zip entry.
Set-ZipEntryContent
-Value <Object[]>
-SourceEntry <ZipEntryFile>
[-Encoding <Encoding>]
[-Append]
[-PassThru]
[<CommonParameters>]
Set-ZipEntryContent
-Value <Object[]>
-SourceEntry <ZipEntryFile>
[-AsByteStream]
[-Append]
[-BufferSize <Int32>]
[-PassThru]
[<CommonParameters>]
The Set-ZipEntryContent
cmdlet can write or append content to a Zip Archive Entry. By default, this cmdlet replaces the existing content of a Zip Archive Entry, if you need to append content you can use the -Append
switch. This cmdlet also supports writing or appending raw bytes while using the -AsByteStream
switch. To send content to Set-ZipEntryContent
you can use the -Value
parameter on the command line or send content through the pipeline.
If you need to create a new Zip Archive Entry you can use the New-ZipEntry
cmdlet.
PS ..pwsh\> $entry = New-ZipEntry .\test.zip -EntryPath test\helloworld.txt
PS ..pwsh\> 'hello', 'world', '!' | Set-ZipEntryContent $entry
PS ..pwsh\> $entry | Get-ZipEntryContent
hello
world
!
You can send content through the pipeline or using the -Value
parameter as shown in the next example.
PS ..pwsh\> Set-ZipEntryContent $entry -Value 'hello', 'world', '!' -Append
PS ..pwsh\> $entry | Get-ZipEntryContent
hello
world
!
hello
world
!
PS ..pwsh\> $entry = Get-ZipEntry .\test.zip -Include test/helloworld.txt
PS ..pwsh\> $bytes = [System.Text.Encoding]::UTF8.GetBytes('hello world!')
PS ..pwsh\> $bytes | Set-ZipEntryContent $entry -AsByteStream
PS ..pwsh\> $entry | Get-ZipEntryContent
hello world!
The cmdlet supports writing and appending raw bytes while using the -AsByteStream
switch.
PS ..pwsh\> $bytes | Set-ZipEntryContent $entry -AsByteStream -Append
PS ..pwsh\> $entry | Get-ZipEntryContent
hello world!hello world!
Using the same byte array in the previous example, we can append bytes to the entry stream.
Appends the content to the zip entry instead of overwriting it.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies that the content should be written as a stream of bytes.
Type: SwitchParameter
Parameter Sets: ByteStream
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
For efficiency purposes this cmdlet buffers bytes before writing them to the Zip Archive Entry. This parameter determines how many bytes are buffered before being written to the stream.
Note
- This parameter is applicable only when
-AsByteStream
is used. The buffer default value is 128 KiB.
Type: Int32
Parameter Sets: ByteStream
Aliases:
Required: False
Position: Named
Default value: 128000
Accept pipeline input: False
Accept wildcard characters: False
The character encoding used to read the entry content.
Note
- This parameter is applicable only when
-AsByteStream
is not used. - The default encoding is
utf8NoBOM
.
Type: Encoding
Parameter Sets: StringValue
Aliases:
Required: False
Position: Named
Default value: utf8NoBOM
Accept pipeline input: False
Accept wildcard characters: False
Outputs the object representing the updated zip archive entry. By default, this cmdlet does not generate any output.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the zip archive entry that receives the content. ZipEntryFile
instances can be obtained using Get-ZipEntry
or New-ZipEntry
cmdlets.
Type: ZipEntryFile
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the new content for the zip entry.
Type: Object[]
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
This cmdlet supports the common parameters. For more information, see about_CommonParameters.
You can pipe strings or bytes to this cmdlet.
This cmdlet produces no output by default .
This cmdlet outputs the updated entry when the -PassThru
switch is used.