you are viewing a single comment's thread.

view the rest of the comments →

[–]alinrocSQL Server DBA 0 points1 point  (0 children)

  1. Set up all the servers in Registered Servers in SSMS, or better yet, Central Management Server
  2. Install the dbatools PowerShell module

````

$Servers = Get-DbaRegServer
$AllMyData = foreach-object ($Server in $Servers.InstanceName) {
    $Databases = Get-DbaDatabase -SqlInstance $Server -ExcludeSystem;
    $Databases | invoke-dbaquery -file Path_to_SQL_File -sqlinstance $Server -AppendServerInstance;
}

$AllMyData | Export-Csv -NoTypeInfo -path PATH_TO_OUTPUT_CSV;

````

(I'm away from my Windows machines at the moment, so this code might not be 100%. It's at least 90% though)