Powershell连接多服务器执行SQL脚本
$query = " select @@servername" $csvFilePath = "c:\Scripts\queryresults.csv" $instanceNameList = get-content c:\Scripts\serverlist.txt $results=@() foreach($instanceName in $instanceNameList) { write-host "Executing query against server: " $instanceName $results += Invoke-Sqlcmd -Query $query -ServerInstance $instanceName } # Output to CSV write-host "Saving Query Results in CSV format..." $results | export-csv $csvFilePath -NoTypeInformation
文章标题:Powershell连接多服务器执行SQL脚本
文章源于:http://ybzwz.com/article/gsscjj.html