I tried to move some files with a certain extension to another folder using powershell, but I can't put multiple values to the variable "$Ext", this is the code I made. can someone help fix my code?
$Date = Get-Date -UFormat %d-%m-%Y
$Source = 'C:\Source\'
$Temp = 'C:\Backup-Temp\'
$Nas = 'D:\Destination\'
$Ext = '*.zip,*.rar, *.txt '
$SetTime = '-5'
New-Item -Path $Temp -Name Backup-$Date -ItemType "directory"
get-childitem -Path $Source/$Ext -Recurse |
Where-object {$_.LastWriteTime -lt (get-date).AddDays($SetTime)} |
Move-item -destination $Temp\Backup-$Date
Compress-Archive -Path $Temp\Backup-$Date -DestinationPath $Nas\Backup-$date.Zip