﻿<?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  / Determining if a server is clustered or stand-alone / 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>Tue, 18 Jun 2013 23:28:41 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>Thanks all - this helped me keep my application event log clean.[code="other"]               bool isClustered = false;                ManagementObjectSearcher searcher = new ManagementObjectSearcher(                                    new ManagementScope(string.Format("\\\\{0}\\root\\cimv2", machineName))                                   , new ObjectQuery("SELECT PartComponent FROM Win32_SystemServices"));                foreach (ManagementObject iQueryObj in searcher.Get())                {                    string name = iQueryObj["PartComponent"].ToString();                    if (name.Contains("ClusSvc"))                    {                        isClustered = true;                    }                }[/code]</description><pubDate>Wed, 06 Mar 2013 11:19:17 GMT</pubDate><dc:creator>jgogel</dc:creator></item><item><title>RE: Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>$s = New-Object Microsoft.SqlServer.Management.Smo.Server("$instancename");$s.IsClustered; # returns $true/$false accordingly.</description><pubDate>Tue, 04 Oct 2011 09:22:35 GMT</pubDate><dc:creator>mendesm</dc:creator></item><item><title>RE: Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>Another option is to look for the cluster service$s = Get-WmiObject -Class Win32_SystemServices -ComputerName $serverif ($s | select PartComponent | where {$_ -like "*ClusSvc*"}) { Write-Output "$server is Clustered" }else { Write-Output "$server is Not clustered" }</description><pubDate>Fri, 30 Sep 2011 11:21:41 GMT</pubDate><dc:creator>bruce 1565</dc:creator></item><item><title>RE: Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>Thanks for the ideas.  I think I've got a solution that works:$s=Get-WMIObject -query "select * from Win32_ComputerSystem" -ComputerName $server | select nameif ($s -ne $server) {	Write-Output "$server is clustered"} else {	Write-Output "$server is not clustered"}Colleen</description><pubDate>Thu, 29 Sep 2011 08:34:35 GMT</pubDate><dc:creator>Colleen M. Morrow</dc:creator></item><item><title>RE: Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>this may be to primitive but you could just use a try catch block to try get-cluster or get-clusternode and have the catch block handle stand-alone servers.</description><pubDate>Tue, 27 Sep 2011 14:54:44 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>colleen i know that via TSQL you can get the serverproperty:would that help?[code]SELECT 'IsClustered', SERVERPROPERTY('IsClustered')[/code]</description><pubDate>Tue, 27 Sep 2011 14:26:14 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Determining if a server is clustered or stand-alone</title><link>http://www.sqlservercentral.com/Forums/Topic1182082-1351-1.aspx</link><description>I'm in the process of writing a powershell script to inventory my SQL Server environment.  In collecting the server information, I'd like to grab the physical hostnames that make up any clustered environments.  I know I can use $nodes=get-clusternode -Cluster SERVERNAME |select nameto get the physical servers in the cluster, but if I run that on a non-clustered server, I get an error, obviously.  So, can someone recommend a good way to determine whether the SERVERNAME I've connected to is a cluster resource group or a physical stand-alone server?</description><pubDate>Tue, 27 Sep 2011 14:14:37 GMT</pubDate><dc:creator>Colleen M. Morrow</dc:creator></item></channel></rss>