Delete files from disk, with a job, respecting some rules ( SQL Server 2008 )
Try something like this:
-Install SQL 2012 feature pack to get invoke-sqlcmd or change it to use sqlcmd.

-You can just pass in the raw TSQL but I would turn it into a stored procedure and just pass that in. Something like:

CREATE PROCEDURE [GetDeleteDate]
AS
select ArquivoServidor from tblExchange
  where DATEDIFF(day,LogDownload,GETDATE())&gt;= 7
    or DATEDIFF(day,LogUpload,GETDATE())&gt;= 30




####Loop through results and execute######
##Define the return as an array by putting it in @()
$lol = @(Invoke-Sqlcmd -Server $ServerInstance -Query "exec [YourAdminDatabase].[dbo].[GetDeleteDate]" | select-object -Expand Column1)  


This will now create an array with the return item as 1 value.  You can now use this array in a loop in powershell to perform whatever work you need done and add error handling.  If you need to then execute a new SQL query and pass in the variable you'd do something like this:

#$lol.Count  ##this is to test how many items are in your array.
foreach ($row in $lol) 
{
#Write-Output $row
Invoke-Sqlcmd -Server $ServerInstance -Query $row -verbose
}


Or if you want to pass the variable as a item to delete in a loop in powershell, feel free to do that too.  The $lol variable is an array with all the data requested.  At that point you can do whatever you need to do with it in PS using the loop above.  It could be a simple del, remove-childitem, etc. Whatever you're comfortable with.  Let us know if you need help writing the delete portion but in the comments you mentioned you're familiar with PS so I figured you could use what you like best.  If you have spaces in your file path make sure to encapsulate it within single or double quotes.