CpuCollection.Count Property

 

Gets the number of Cpu entries in the collection.

Namespace:   Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public int Count { get; }

Property Value

Type: System.Int32

Returns the number of Cpu entries in the collection. The return type is an T:System.int value.

The following example shows how to determine the total number of CPUs on an instance of SQL Server.

C#

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Server dbServer = new Server("(local)");
            dbServer.Refresh();
            Console.WriteLine("Total CPUs: {0}",
                dbServer.AffinityInfo.Cpus.Count);
        }
    }
}

Powershell

$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.Refresh()
Foreach ($cpu in $dbServer.AffinityInfo.Cpus)
{
   Write-Host "Total CPUs:" $dbServer.AffinityInfo.Cpus.Count
}
Return to top
Show: