發表文章

目前顯示的是 2月 27, 2019的文章

PowerShell script not zipping correct files

圖片
2 3 Function Zip { Param ( [string]$zipFile , [string]$toBeZipped ) $CurDir = Get-Location Set-Location "C:Program Files7-Zip" .7z.exe A -tzip $zipFile $toBeZipped | Out-Null Set-Location $CurDir } $Now = Get-Date $Days = "60" $TargetFolder = "C:usersAdminDownloads*.*" $LastWrite = $Now.AddDays(-$Days) $Files = Get-Childitem $TargetFolder -Recurse | Where {$_.LastWriteTime -le "$LastWrite"} $Files Zip C:UsersAdminDesktopTEST.zip $Files I am testing out this script I found online. My problem is that instead of zipping the files in the target folder, it is copying and zipping the contents of the 7-zip program file folder. What could cause this? Thanks in advance