Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Run A query on Multiple servers using CMS Expand / Collapse
Author
Message
Posted Saturday, December 29, 2012 4:55 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:07 PM
Points: 19, Visits: 116
Hi ,

I want to run a query on Multiple servers i am using CMS to run it on multiple on server.
Now i want to automate this through job,powershell,sqlcmd ...and the result should export to CSV.
Pls help.
Post #1401212
Posted Monday, December 31, 2012 12:10 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:21 AM
Points: 7,135, Visits: 12,749
Those requirements are a bit vague. Are you running a select statement? An update? What will your CSV look like?

Here is some boilerplate PowerShell code to help you get you started interacting with your CMS.

$serverGroupPath = 'SQLSERVER:\SQLRegistration\Central Management Server Group\<GroupName>\'
$instanceNameList = dir $serverGroupPath -recurse | where-object { $_.Mode.Equals("-") } | select-object Name -Unique

foreach($instanceName in $instanceNameList)
{
# do something against each server here
}


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1401472
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse