简体   繁体   中英

Powershell - Copy backup folder from single Source to Multiple-Destinations

I have a t-sql query that returns a collections of paths.

I need, given a source folder/path, to copy such folder, and its files to the destinations.

My question is, given this query :

SELECT [MasterDBLocation] FROM [DBBackupMasterLocation] 

Results :

\\BASELINES17.newgen.corp\Baselines
\\BASELINES23.newgen.corp\Baselines

how do I store the results of that query in powershell, and then loop through all paths, to copy the folder from source to all paths returned by that query?

Thank you!

Just do this:

$Data = SQL_Query "SELECT MasterDBLocation FROM DBBackupMasterLocation"

Export-Csv -InputObject $Data -Path "C:\Main\Data.csv"

Copy-Item -Path "C:\Main\Data.csv" -Destination "D:\Backuo\Data.csv"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM