Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Write-Zip

Write-Zip

pscx.dll

Synopsis

PSCX Cmdlet: Create ZIP format archive files from pipline or parameter input.

Syntax

Write-Zip [-LiteralPath] [-OutputPath] [-Append] [-FlattenPaths] [-IncludeEmptyDirectories] [-Level] [-NoClobber] [-Quiet] [<CommonParameters>]

Write-Zip [-InputObject] [-EntryPathRoot] [-Append] [-FlattenPaths] [-IncludeEmptyDirectories] [-Level] [-NoClobber] [-Quiet] [<CommonParameters>]

Write-Zip [-Path] [-Append] [-FlattenPaths] [-IncludeEmptyDirectories] [-Level] [-NoClobber] [-Quiet] [<CommonParameters>]

Detailed Description

Create ZIP format archive files from pipline or parameter input.

Parameters

-LiteralPath <String[]>

Specifies a path to the item. The value of -LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

Aliases

None

Required?

true

Position

1

Default value

N/A

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Path <String[]>

Specifies the path to the file to process. Wildcard syntax is allowed.

Aliases

None

Required?

true

Position

1

Default value

N/A

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

true

-InputObject <PSObject>

Accepts an object as input to the cmdlet. Enter a variable that contains the objects or type a command or expression that gets the objects.

Aliases

None

Required?

true

Position

named

Default value

N/A

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-EntryPathRoot <String>

Aliases

None

Required?

false

Position

2

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-OutputPath <String>

If set, a single archive will be created with all input files stored in it. If not set, each archive will be stored in a separate archive in the current directory. This must be set to an output filename, not a directory.

Aliases

None

Required?

false

Position

2

Default value

Not set.

Accept pipeline input?

false

Accept wildcard characters?

false

-Append <SwitchParameter>

If set, the input files will be added to, or updated in, the zip file specified by OutputPath.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-FlattenPaths <SwitchParameter>

If set, no path information will be stored in the archive, effectively placing all files in the root. Files in subdirectories matching those in lower levels with clashing names will not be added and a warning will be emitted.

Aliases

None

Required?

false

Position

named

Default value

Not set.

Accept pipeline input?

false

Accept wildcard characters?

false

-IncludeEmptyDirectories <SwitchParameter>

If set, empty directories will be added as entries into the archive.

Aliases

None

Required?

false

Position

named

Default value

Not set.

Accept pipeline input?

false

Accept wildcard characters?

false

-Level <Nullable`1>

Can be set between 1 and 9 inclusive. Higher numbers use a more efficient compression method, resulting in smaller archives. Higher levels generally result in slower compression times.

Aliases

None

Required?

false

Position

named

Default value

5

Accept pipeline input?

false

Accept wildcard characters?

false

-NoClobber <SwitchParameter>

If set, existing archives with the same name as the current output archive will not be overwritten.

Aliases

None

Required?

false

Position

named

Default value

Not set, existing archives with the same name WILL be overwritten.

Accept pipeline input?

false

Accept wildcard characters?

false

-Quiet <SwitchParameter>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type




Return Type


Notes

When passing DirectoryInfo objects via the pipeline, the Cmdlet will NOT iterate their contents. However, if you pass a directory name via -Path, they WILL be iterated for contents.

Examples

-------------------------- EXAMPLE 1 --------------------------

This will zip the contents of the Desktop directory into the file desktop.zip.

        PS> write-zip .\Desktop desktop.zip
      

-------------------------- EXAMPLE 2 --------------------------

This will recursively search C:\logs for *.log files, compress them with maximum compression, move them to c:\archived_logs and then delete the original.

        PS> dir c:\logs\ -rec -inc *.log | write-zip -level 9 -removeoriginal | move-item c:\archived_logs\