x
login about faq Site discussion (meta-askssc)

Powershell Register Servers - How do I add a connection property?

I have a little PS script that Buck Wooody posted a while back. I use it to generate a refreshed list of registered servers in a given server group. I would like to add the Custom Color property to the script but haven't been able to find it anywhere. Any help would be appreciated.

This is the script:

cd 'SQLSERVER:\sqlregistration\Database Engine Server Group'

rm group_name -recurse

new-item group_name

cd group_name

new-item SERVERNAME -itemtype registration -Value "server=SERVERNAME;integrated security=true"
..........
more ▼

asked Oct 19 '09 at 03:40 PM in Default

Mark 1 gravatar image

Mark 1
11 1 1 1

(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first

Answering separately since this is a complete other solution but you can install SSMS Tools pack (its free) and get that same functionality without having to code at all.

http://ssmstoolspack.com

more ▼

answered Oct 19 '09 at 04:00 PM

Jorge Segarra gravatar image

Jorge Segarra
419 2

I have the tools pack. It colors the Query just under the tab and colors are different for each query. The Custom Color on the Connect property is the connection information at the bottom of the Query. I have setting up a color for Production servers (red), a color for Dev servers (green).

Oct 19 '09 at 04:16 PM Mark 1
(comments are locked)
10|1200 characters needed characters left

I'm trying to find the recording for the webcast where Buck demonstrates this. Here's one I've found so far (will edit with more links later)

https://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032391436&EventCategory=5&culture=en-US&CountryCode=US

Here's the script you were looking for:

http://blogs.msdn.com/buckwoody/archive/2009/10/14/color-your-connections.aspx

more ▼

answered Oct 19 '09 at 03:58 PM

Jorge Segarra gravatar image

Jorge Segarra
419 2

(comments are locked)
10|1200 characters needed characters left

I found this same code on Bob Beauchemin's blog.

Anyway, since you're creating a registration item, you should be able to get your new registration as an object immediately after you create it:

$srv = get-item SERVERNAME;

Once you have this object, you can then theoretically use it's methods to change it's properties through SMO:

$srv.set_UseCustomConnectionColor($True); $srv.set_CustomConnectionColorArgb(-16711936);

--I took the values for these functions from an existing registration I made in SSMS. The ColorArgb is supposed to be green.

However, Bob's note at the bottom of his blog post about the changes made in PowerShell not showing up immediately in SSMS seem to be the case whenever I test. In fact, I can never seem to get the changes to show up in SSMS...ever.

I'm happy to be proven wrong, but my guess is that the new-item cmdlet doesn't quite make the Registration properly enough that you can modify it's properties through SMO.

more ▼

answered Oct 19 '09 at 11:43 PM

Tim Benninghoff gravatar image

Tim Benninghoff
43 1 1 3

More testing: I notice that those properties, UseCustomConnect ionColor and CustomConnectionColorArgb, have reset back to their defaults (False and 0, respectively) once I leave PowerShell and then restart PowerShell.

Oct 19 '09 at 11:54 PM Tim Benninghoff

Thanks Tim - I played with it a bit and can't make it "stick" either.

Oct 20 '09 at 11:42 AM Mark 1
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x272
x19
x18

asked: Oct 19 '09 at 03:40 PM

Seen: 2003 times

Last Updated: Oct 20 '09 at 06:03 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.