November 20, 2015 at 3:55 pm
How do I automatically detect the list of all SQL servers/instance within a specific domain having 2000 ,2005 ,2008,2012 sql servers and dump all the servernames to a text file and automate this process.
Thanks
I havefound this powershell script online.
[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()
I have scheduled it as part of a SQL job and it directs output to a text file.
But it gives me a list of columns servername,version etc,...
How do I only get the servername column without the servername heading in the text extract.
Thanks
Currently the text extract looks as underneath when I run the powershell script within a SQL job.
ServerName InstanceName IsClustered Version
---------- ------------ ----------- -------
ABCDEFGHI No 10.0.4000.0
ABCDEFGHI MSSQLSERVER2012 No 11.0.3000.0
SFVSDVSDV No 11.0.5058.0
HDDBHDGHH No 10.50.1600.1
But I want my text extract to only look like this without any column header or in a delimited format (pipe / tab)
ABCDEFGHI
ABCDEFGHI
SFVSDVSDV
HDDBHDGHH
Thanks
November 20, 2015 at 5:10 pm
There's a bunch of ways to do this using T-SQL, a CLR, Powershell, cmdexec, etc. You should copy an attachment of what the text file looks like (you don't need real info in there) and upload it here. Explain what you want the text file to look like. I'm sure you'll get an answer.
-- Itzik Ben-Gan 2001
November 23, 2015 at 4:55 am
Using only Powershell you can do this:
[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | SELECT ServerName | Format-Table -HideTableHeaders
MCITP SQL 2005, MCSA SQL 2012
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply