Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

powershell Decompress zip file

$
0
0

Hi,

I'm trying to write a script that reads a zip file and extracts only the files that have a particular extension.

It works when I specify:

[String]$zipfiles = (Get-ChildItem "E:\zips\" "*.zip").Fullname 

But errors when I specify:

[String]$zipfiles = Get-ChildItem "E:\zips\" "*.zip" | sort LastWriteTime | Select Fullname -ExpandProperty Fullname | Out-String 

With the message:

Exception calling "OpenRead" with "1" argument(s): "Illegal characters in path."

I'm passing the file path to OpenRead within a foreach object loop:

[IO.Compression.ZipFile]::OpenRead($zipfile).Entries

I can't see the illegal character and get member for both shows system.string and they both look identical to me.

Any ideas?


Viewing all articles
Browse latest Browse all 6937

Trending Articles