This is the first time I am posting here so please forgive my formatting:
I am using a script to remove files from a specific folder that have a specific extension after a given amount of time. When I specify the file in the script it works great. However I have multiple folders that will need to be used. I added the files into a .csv file to pull from and the script does not work. Can anyone tell me where I am going wrong?
Script:
#
#----- define parameters -----#
#----- get current date ----#
$Now = Get-Date
#----- define amount of days ----#
$Days = "10"
#----- define folder where files are located ----#
$TargetFolder = import-csv "C:\users\administrator\documents\targetfiles1.CSV"
#----- define extension ----#
$Extension = "*.txt"
#----- define LastWriteTime parameter based on $Days ---#
$LastWrite = $Now.AddDays(-$Days)
#----- get files based...