Expand-ZipEntry

Synopsis

Extracts entries from a compressed archive to Zip format.

Syntax

Expand-ZipEntry -ZipFile <ZipFile> [-Name] <String[]> [-ExtractAction <ExtractExistingFileAction>] [-Password <String>] [-Encoding <Encoding>] [-AsHashTable] [-Strict] [<CommonParameters>]

Expand-ZipEntry -ZipFile <ZipFile> [-Name] <String[]> [-ExtractAction <ExtractExistingFileAction>] [-Password <String>] [-Encoding <Encoding>] [-AsHashTable] [-Byte] [-Strict] [<CommonParameters>]

Expand-ZipEntry -ZipFile <ZipFile> [-Name] <String[]> [-ExtractAction <ExtractExistingFileAction>] [-Password <String>] [-Encoding <Encoding>] [-AsHashTable] [-XML] [-Strict] [<CommonParameters>]

Description

Extracts entries from a compressed archive to a Zip format. Extracted data are either serialized data, either an array of bytes, or a string and it allows to build an object. To extract files from an archive use 'Expand-ZipFile' Cmdlet.

Parameters

-ZipFile <ZipFile>

An object containing a Zip archive.

Required? True
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Name <String[]>

Names of entries to extract.

Required? True
Position? 1
Default value  
Accept pipeline input? true (ByValue)
Accept wildcard characters? False

-ExtractAction <ExtractExistingFileAction>

Specific steps to be taken when data is already present in the destination folder.Values : Throw, OverwriteSilently, DoNotOverwrite, InvokeExtractProgressEvent

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Password <String>

Password used to uncompress encrypted archive.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Encoding <Encoding>

Archive encoding type. Possible values are : -ASCII : ASCII characters encoding scheme (7 bits). -BigEndianUnicode : encoding for the UTF-16 format using the big endian byte order. -Default : encoding for the operating system's current ANSI code page. -Unicode : encoding for the UTF-16 format using the little endian byte order. -UTF32 : encoding for the UTF-32 format using the little endian byte order. -UTF7 : encoding for the UTF-7. -UTF8 : encoding for the UTF-8. . For better portability, the default value ('DefaultEncoding') is recommended.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-AsHashTable <SwitchParameter>

Returns readen entries into an object of type hashtable. Name entries are extracted as a key name.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Strict <SwitchParameter>

Errors trigger exceptions in place of displaying them.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Byte <SwitchParameter>

Entry is returned as an array of bytes.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-XML <SwitchParameter>

String object is returned in XML format.

Required? False
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? False

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

String[]

Outputs

System.Xml.XmlDocument

Notes

This function is linked to the Add-ZipEntry function.

Examples

EXAMPLE 1

PS C:\> try {         
$ZipFile=Get-Zipfile -Path C:\Temp\Test.zip
[string]$Text=Get-Content C:\Temp\Test.ps1|Out-String
Add-ZipEntry -Object $Text -Name MyText -ZipFile $ZipFile
} finally {
$ZipFile.Close()
}
Remove-Variable Text
try {
$ZipFile=Get-Zipfile -Path C:\Temp\Test.zip 
[string]$Text =Expand-ZipEntry -Zip $ZipFile MyText   
} finally {
if ($ZipFile -ne $null )
{ $ZipFile.PSDispose() }
}

At first time, those instructions save text to an entry named MyText, then links it and assigns it to the ''$MyVersionArray'' variable.

EXAMPLE 2

PS C:\> try {
$ZipFile=Get-Zipfile -Path C:\Temp\Test.zip         
ConvertTo-CliXml $PSVersionTable | Add-ZipEntry -Name 'PSVersiontable_clixml' -ZipFile $ZipFile
} finally {
$ZipFile.Close()
}

try {
$ZipFile=Get-Zipfile -Path C:\Temp\Test.zip 
$MaTableDeVersion=Expand-ZipEntry -Zip $ZipFile 'PSVersiontable_clixml'|ConvertFrom-CliXml   
} finally {
if ($ZipFile -ne $null )
{ $ZipFile.PSDispose() }
}
$MaTableDeVersion

At first time, those instructions save serialized object to an entry named ''PSVersiontable_clixml'', then links and assigns it to the $MyVersionArray variable.

EXAMPLE 3

PS C:\> try {         
$ZipFile=Get-Zipfile -Path C:\Temp\Test.zip 
[byte[]] $Array=@(1..20)
Add-ZipEntry -Object $Array -Name MyArray -ZipFile $ZipFile
} finally {
$ZipFile.Close()
}
Remove-Variable Array
try {
$ZipFile=Get-Zipfile -Path C:\Temp\Test.zip 
$Array=Expand-ZipEntry -Zip $ZipFile MyArray -Byte   
} finally {
if ($ZipFile -ne $null )
{ $ZipFile.PSDispose() }
}

At first time, those instructions save an array of bytes to an entry named ''MyArray'', then links it and assigns it to the ''$Array'' variable.

Related links

Unknown https://psionic.codeplex.com/wikipage?title=Expand-ZipEntry-EN

PowerShell Support

  • PowerShell 2.0

Operating System Support

  • Windows 7
  • Windows 8
  • Windows 8.1
  • Windows Server 2008 all editions
  • Windows Server 2008 R2 all editions
  • Windows Server 2012 all editions
  • Windows Server 2012 R2 all editions

Last edited May 14, 2014 at 10:50 AM by LaurentDardenne, version 9

Comments

No comments yet.