I’m trying to remove files from a server. I have a csv that contains the path in one field and the name of the file in another field. I’d like to concatenate the two fields together so that I delete only the files that are specified (otherwise it would just delete everything in the path).
Here’s the nonworking code with the two field names that I need to reference:
Import-Csv C:\CSVs\TestDelete.csv | Foreach-Object {
Remove-Item -LiteralPath $_.Path + $_.Name -WhatIf
}
This assumes your ‘path’ data has a trailing ‘\’: