Hi all--I need to run the stored procedure "sp_validatelogins" against multiple SQL instances. I know the basic technique to fill in data:
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $Server; Database = master; Integrated Security = True"
## Build the SQL command
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = 'exec sp_validatelogins'
$SqlCmd.Connection = $SqlConnection
## Execute the query
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
## Return the dataset
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$results += $DataSet.Tables[0]
I'm trying to customize the output from this:
SID NT Login
--- --------
{1, 5, 0, 0...} CORP\user1
What would be the best method to create this output?
ComputerName NT Login
----------------- ----------
server1 CORP\user1
server1 CORP\user2
...