0

Does anyone have idea on how to get results for different server name in different worksheet tab for this PowerShell command below

$instance = 'Server129','server320','server540'
$serverRole ='sysadmin','diskadmin'
$db5 = Get-DbaServerRoleMember -SqlInstance:$instance -ServerRole:$serverRole | ft
$db5 | Out-File c:\testopii.csv
Vivek Kumar Singh
  • 3,223
  • 1
  • 14
  • 27
Mario
  • 1
  • You cannot generate multiple tabs for CSV file. What you can do is export the result of each of the server individually into different CSVs and then refer to [this](https://stackoverflow.com/questions/49324636/multiple-csv-files-into-a-xlsx-file-but-different-sheets-using-powershell) link and merge them as different sheets of an excel file. – Vivek Kumar Singh Dec 22 '20 at 10:20
  • Also `Get-DbaServerRoleMember` returns **objects**. You destroy these by piping it to `Format-Table` which is a cmdlet for display purposes only. Trying to output that display to a file with `Out-File` will never result in a workable CSV file. – Theo Dec 22 '20 at 12:09

0 Answers0