none
PowerShell - Zipar Arquivos RRS feed

Respostas

  • Consegui, utilizando o script abaixo:

    $mes= Get-Date -Format "MMdyyyy"
    $SourceFolder    = "C:\XP\XP.Automate.CMTIMS.TH\temp\$mes"
    $DestinationFile = "\\fsxp\internacional\CM TIMS Timber Hill\2015"
    $Compression     = "Optimal"  # Optimal, Fastest, NoCompression

    Zip-Directory -DestinationFileName $DestinationFile `
        -SourceDirectory $SourceFolder `
        -CompressionLevel $Compression ` #Optional parameter
        -IncludeParentDir #Optional parameter

    function Zip-Directory {
        Param(
          [Parameter(Mandatory=$True)][string]$DestinationFileName,
          [Parameter(Mandatory=$True)][string]$SourceDirectory,
          [Parameter(Mandatory=$False)][string]$CompressionLevel = "Optimal",
          [Parameter(Mandatory=$False)][switch]$IncludeParentDir
        )
        Add-Type -AssemblyName System.IO.Compression.FileSystem
        $CompressionLevel    = [System.IO.Compression.CompressionLevel]::$CompressionLevel  
        [System.IO.Compression.ZipFile]::CreateFromDirectory($SourceDirectory, $DestinationFileName, $CompressionLevel, $IncludeParentDir)


    Carlinhos IT

    • Marcado como Resposta Carlinhos IT sexta-feira, 31 de julho de 2015 19:53
    sexta-feira, 31 de julho de 2015 19:53