Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

how to unzip the latest file in a folder

$
0
0

I have found this code on internet which is perfect the only problem is how to use get-childitem in this code so that it copies the most recent zip file and unzips it. here is the code.

$path = "C:\Deployments"
$destination = "C:\_Temp"
$shell_app= New-Object -com shell.application

$files = Get-ChildItem -Path $path -filter *.zip -recurse

   foreach($file in $files) {

    $zip_file = $shell_app.namespace($file.FullName)

     $copyHere = $shell_app.namespace($destination)

  $copyHere.Copyhere($zip_file.items())

}

   

Viewing all articles
Browse latest Browse all 15028

Trending Articles