Differences

This shows you the differences between the selected revisions of the page.

2017-10-04 2017-10-04
using variable expansion in strings in powershell (martin) code wrapping for new design (martin)
Line 87: Line 87:
        if ($PSVersionTable.PSVersion.Major -lt 3)         if ($PSVersionTable.PSVersion.Major -lt 3)
        {         {
-            throw "PowerShell 3.0 and newer is required. Please, upgrade PowerShell. Or try using the 7-zip mode instead."+            throw ("PowerShell 3.0 and newer is required."
 +                  "Please, upgrade PowerShell. Or try using the 7-zip mode instead.")
        }         }
Line 93: Line 94:
        Add-Type -AssemblyName "System.IO.Compression.FileSystem"         Add-Type -AssemblyName "System.IO.Compression.FileSystem"
-        $zip = [System.IO.Compression.ZipFile]::Open($archivePath, [System.IO.Compression.ZipArchiveMode]::Create)+        $zip = 
 + ···········[System.IO.Compression.ZipFile]::Open( 
 +················$archivePath, [System.IO.Compression.ZipArchiveMode]::Create)
        # Replace with Compress-Archive once PowerShell 5.0 is widespread         # Replace with Compress-Archive once PowerShell 5.0 is widespread
Line 107: Line 110:
            else             else
            {             {
-                $files = Get-ChildItem $localPath -Recurse -File | Select-Object -ExpandProperty FullName+                $files = 
 + ···················Get-ChildItem $localPath -Recurse -File | 
 + ···················Select-Object -ExpandProperty FullName
            }             }
Line 114: Line 119:
                $entryName = $file.Replace(($parentPath + "\"), "")                 $entryName = $file.Replace(($parentPath + "\"), "")
                Write-Host "Adding $entryName..."                 Write-Host "Adding $entryName..."
-                [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $file, $entryName) | Out-Null+                [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile( 
 +····················$zip, $file, $entryName) | Out-Null
            }             }
        }         }

Last modified: by martin