# serverList.txt has name of fully qualified sql instance ( one per line)
# Example entries:
# server1
# server1\instance1
$instanceNameList = Get-Content C:\ServerList.txt
foreach($instanceName in $instanceNameList)
{
$results += Invoke-Sqlcmd -Query "select SERVERPROPERTY('ServerName') As ServerName, Name, crdate from sysdatabases" -ServerInstance $instanceName.Name
}
# print results
$results
# This posting is provided "AS IS" with no warranties, and confers no rights.
# Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
If you would like to execute query against a Central Management Server group, refer to blog entry http://blogs.msdn.com/b/sethus/archive/2009/04/09/execute-a-query-on-servers-in-central-management-server-group.aspx
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified athttp://www.microsoft.com/info/cpyright.htm