Hi,
Does this work for you?
$servers = 'DESKTOP-6U9IKQD','DESKTOP-6U9IKQD\bm'
$result = Invoke-DbaQuery -ServerInstance $InstanceList -Query $sql -AppendServerInstance
foreach($server in $servers){
$result | Where-Object {$_.ServerInstance -eq $server} | Out-File -FilePath C:\b2\output1.txt -Append
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.