I have a set of files named as: 20161205_abc, 20161205_bcd, 20161205_cde, 20161206_abc, 20161204_abc.
I have a script in place to zip all the files who have names like: 20161205*.
Add-Type -assembly 'System.IO.Compression'
[string]$zipFN = 'u:\users\riteshthakur\desktop\myZipFile.zip'
[string]$fileToZip = 'u:\users\riteshthakur\desktop\abc\20161205*.txt'
[System.IO.Compression.ZipArchive]$ZipFile = [System.IO.Compression.ZipFile]::Open($zipFN, ([System.IO.Compression.ZipArchiveMode]::Create))
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($ZipFile, $fileToZip, (Split-Path $fileToZip -Leaf))
$ZipFile.Dispose()
This throws error: "Exception calling "CreateEntryFromFile" with "3" argument(s): "Illegal characters in path." At U:\Users\riteshthakur\Desktop\Zip.PS1:7 char:1 + [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($ZipFile, $fileTo ..."
Please help.
CreateEntryFromFile()takes exactly one file as its second argument, it won't treat*as a wildcard*in$fileToZip.