SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Deploy Script To SQL Databases using Powershell


Deploy Script To SQL Databases using Powershell

Author
Message
zulmanclock
zulmanclock
Mr or Mrs. 500
Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)Mr or Mrs. 500 (598 reputation)

Group: General Forum Members
Points: 598 Visits: 491
Hello all.
I am new to powershell and have a question. Is there a way to deploy sql scripts to all the databases that are in a registered server in the central management list on sql? I would like to avoid looping thru a list of databases and have the script run on all of them simultaneously like it would if i used the multi script tool.

Also, i have a ps script that i think should give me the servers in my Central Management group but it comes up with nothing even though i have servers registered. Any help would be greatly appreciated.

I am using a remote powershell connection to my support server when running the below.

#import SQL Server module
Import-Module SQLPS -DisableNameChecking
Set-Location "SQLSERVER:\SQLRegistration\Central Management Server Group"
Get-ChildItem

this returns nothing.
VishnuGupthanSQLPowershellDBA
VishnuGupthanSQLPowershellDBA
Mr or Mrs. 500
Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)Mr or Mrs. 500 (553 reputation)

Group: General Forum Members
Points: 553 Visits: 410
Hi
Please try the modification made in your script in RED.

#import SQL Server module
Import-Module SQLPS -DisableNameChecking
Set-Location "SQLSERVER:\SQLRegistration\Central Management Server Group\<<CentralManagementSQLServerMame>>"
Get-ChildItem
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search