|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: 2 days ago @ 5:43 AM
Points: 10,
Visits: 52
|
|
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.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 6:57 PM
Points: 6,724,
Visits: 11,771
|
|
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
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|