I am trying to copy multiple files from one location to another. I have the source path and destination path in SQL table. Is there a way in powershell to loop through each of the row from the result set of SQL table and use "Copy-item" for each row.
Below is the what I have so far, I want to use foreachloop and go through each row and copy file from source to destination.
$select_query = "select source_path, destination_path from table_commands order by id"$copy_commands = Invoke-Sqlcmd -ServerInstance "server_name" -Database "database_name" -Query $select_query | select source_path, destination_path
Copy-Item $source_path -Destination $destination_path