function cee([string]$a,
[string]$b)
{
Write-Host $a | ft
$a.GetType()
Write-Host $b | ft
$b.GetType()
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($a,$b)
}
cee('C:\FAKE','C:\zipfile.zip')
When run in this manor it fails and errors with:
C:\FAKE'C:\zipfile.zip
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object >True True String System.Object
Exception calling "CreateFromDirectory" with "2" argument(s): "The given >path's format is not supported." At line:10 char:9 + [System.IO.Compression.ZipFile]::CreateFromDirectory($a, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : NotSupportedException
If I store 'C:\FAKE\' and 'C:\zipfile.zip' as variables, manually running each line with the variables as input for $a and $b, it works just fine.
If I set [Parameter(Mandatory=$True)] , run the function, and enter C:\FAKE\ and C:\zipfile.zip at the prompt, it works just fine.