I need to take the first 3 zip folder sorted by date and then extract them into a specific folder I tried this script but it doesn't work
percorso = Get-ChildItem -Path 'C:\first'| Sort-Object LastWriteTime -Descending
ForEach ($file in (Get-ChildItem -Path "C:\first")[0..2]){Expand-Archive -DestinationPath 'C:\Users\second' -Force}
thanks
I think it should be the below. You weren't passing the source file path to Expand-Archive at all.
$AllFiles = Get-ChildItem -Path 'C:\first'| Sort-Object LastWriteTime -Descending
ForEach ($File in $AllFiles[0..2]){
Expand-Archive -Path $File -DestinationPath 'C:\Users\second' -Force}