I have xml file which contains names of few files. I want to read those file names and pass it as a comma seperated string to Exclude command in power shell.
What I have tried:
I have xml file which contains names of few files.
I am using below command to delete files from \\Test\abc location. However, while deleting files, I don't want to delete those files which contains "abc" or "xyz" in their file name.
In future, I may need to exclude the files which has "pqr" (say) in their file name. So instead of hard coding it in below command, I need to include all those words in xml file. I will read that xml file and pass those names as comma seperated string as a parameter to "Exclude" in below command.
Get-ChildItem –Path "\\Test\abc" -Exclude *abc*,*xyz* -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-4)} | Remove-Item
Please let me know how I can read the xml file and pass the values as a comma seperated string to Exclude command ?