﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / Powershell  / Query local SSMS server group with Powershell? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 19:59:01 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>[quote][b]MG-148046 (12/27/2012)[/b][hr]You could use the stucture available in SQLPS. Set your location to SQLSERVER:\SQLRegistration\Database Engine Server Group\&amp;lt;your group name&amp;gt;[/quote]Nice, didn't know about that location! Certainly easier than parsing the XML file!</description><pubDate>Wed, 02 Jan 2013 04:50:46 GMT</pubDate><dc:creator>Gazareth</dc:creator></item><item><title>RE: Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>[quote][b]MG-148046 (12/27/2012)[/b][hr]You could use the stucture available in SQLPS. Set your location to SQLSERVER:\SQLRegistration\Database Engine Server Group\&amp;lt;your group name&amp;gt; then set a variable equal to get-childitem and do a foreach loop over each server in the group.A simple example:Set-Location SQLSERVER:\SQLRegistration\Database Engine Server Group\&amp;lt;your group name&amp;gt; $servers = get-childitemforeach ($server in $server) {&amp;lt;do something herer&amp;gt;}[/quote]I like the text file or database table only because it's portable. Here is more info on it. It requires the installation of some add-ons to make sqlps importable into your PoSh sessions.[u][url=http://www.sqlskills.com/blogs/bobb/post/programming-sqlregistration-in-the-sql-server-powershell-provider.aspx]Programming SQLRegistration in the SQL Server PowerShell Provider[/url][/u]</description><pubDate>Thu, 27 Dec 2012 08:54:51 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>You could use the stucture available in SQLPS. Set your location to SQLSERVER:\SQLRegistration\Database Engine Server Group\&amp;lt;your group name&amp;gt; then set a variable equal to get-childitem and do a foreach loop over each server in the group.A simple example:Set-Location SQLSERVER:\SQLRegistration\Database Engine Server Group\&amp;lt;your group name&amp;gt; $servers = get-childitemforeach ($server in $server) {&amp;lt;do something herer&amp;gt;}</description><pubDate>Thu, 27 Dec 2012 06:40:16 GMT</pubDate><dc:creator>MG-148046</dc:creator></item><item><title>RE: Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>Thank you both (Gazareth &amp; opc.three) for taking the time to reply. I will likely end up going the route of a servers.txt file, I was just trying to find a way around it and in typical fashion was probably over thinking it a bit I guess. In any case, I do appreciate the feedback.DT</description><pubDate>Wed, 26 Dec 2012 06:46:11 GMT</pubDate><dc:creator>dtibz01</dc:creator></item><item><title>RE: Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>Have you heard of [u][url=http://msdn.microsoft.com/en-us/library/bb895144.aspx]Central Management Server[/url][/u] (CMS)? It supports the "interact with each server in a server group from PowerShell" functionality that I think you are after.If setting up a CMS is not something you want to begin doing then I would also look into storing the list of servers in a text file and using something like [code="plain"]foreach ($server in (Get-Content C:\myservers.txt)){Write-Host $server;}[/code]or something similar with the servers stored in a utility database somewhere instead of a text file.</description><pubDate>Mon, 24 Dec 2012 13:34:29 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>Well, if you can get the information out of the file, registered servers are stored inC:\Users\username\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\RegSrvr.xmlBut I'd be much more tempted to set up my own text file or db table to store the server/database information.Easy enough once you've got the list to run your query in a foreach loop.</description><pubDate>Fri, 07 Dec 2012 09:02:31 GMT</pubDate><dc:creator>Gazareth</dc:creator></item><item><title>Query local SSMS server group with Powershell?</title><link>http://www.sqlservercentral.com/Forums/Topic1393651-1351-1.aspx</link><description>This may be a totally off the wall question, but it seems like it should be possible to do. Just can't find any specifics as to how I might accomplish it.I have a situation in that I have the same database (structurally) across multiple SQL Server instances, with different database names. Through SSMS I have a local server group defined that references each unique instance and individual database. This allows me query each database at once with a single SQL statement, regardless of database name.When queries are run through my SSMS environment, I have the option enabled to return the SQL Server instance in the grid output so the instance name is returned with each row. I would like to automate running my query and outputting the results to Excel via Powershell script.What I'm hung up on is that I need to be able (with Powershell) to reference my SSMS local server group as the the data source that the query runs against, and run the query. Has anyone done this? I appreciate any feedback..</description><pubDate>Thu, 06 Dec 2012 10:53:08 GMT</pubDate><dc:creator>dtibz01</dc:creator></item></channel></rss>