ConvertTo-PSZipEntryInfo

Synopsis

Converts Info property of a ZipFile or ZipEntry object.

Syntax

ConvertTo-PSZipEntryInfo [[-Info] <String>] [<CommonParameters>]

Description

Converts Info property of a ZipFile object to a custom objects list or a ZipEntry/PSZipEntry object to a custom object.

Parameters

-Info <String>

Contents of a Ionic object's Info property.

Required? False
Position? 0
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

System.String

Outputs

PSCustomObject

Notes

The Info property conversion into several objects takes some time. Avoid to convert this property several times into a loop. Be aware that an instance can evolve by adding or removing an entry. In this case, you need to update this field (ZipEntry/PSZipEntry) or build a new list (ZipFile).

Examples

EXAMPLE 1

PS C:\> $PSEntries=Get-ZipFile -Path .\Test.zip -List 
$PSEntries[0].Info=ConvertTo-PSZipEntryInfo $PSEntries[0].Info
$PSEntries[0].Info.Zipentry

This example gets an entry list from an archive. Those are Powershell custom objects. The Info property (which is string type by default), is converted to a PSObject. Then this PSObject is reassigned to the contents of the Info property. The string type initial information is no longer available.

EXAMPLE 2

PS C:\> try {
$Zip=Get-ZipFile -Path .\Test.zip         
Add-Member -Input $Zip -Force NoteProperty Info (ConvertTo-PSZipEntryInfo $Zip.Info)
$Zip.Info[0].ZipEntry
$File=Get-Item C:\Temp\Test.ps1
Add-ZipEntry -Object $File -ZipFile $Zip
Add-Member -Input $Zip -Force NoteProperty Info (ConvertTo-PSZipEntryInfo $Zip.psbase.Info)
} finally {
if ($Zip -ne $null )
{ $Zip.PSDispose() } 
}

This example gets an archive then its Info property is converted to an indexed list of PSZipEntryInfo objects. Then it adds a new entry to the archive and it builds a new PSZipEntryInfo list, this time from the initial information which is reachable through $Zip.psbase.Info.

Related links

Unknown https://psionic.codeplex.com/wikipage?title=ConvertTo-PSZipEntryInfo-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 2:13 PM by LaurentDardenne, version 5

Comments

No comments yet.