十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
$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