AffinityInfo.Cpus AffinityInfo.Cpus AffinityInfo.Cpus Property

Definition

The Cpus member is a collection that represents the CPU settings for all CPUs on an Instance of SQL Server.

public:
 property Microsoft::SqlServer::Management::Smo::CpuCollection ^ Cpus { Microsoft::SqlServer::Management::Smo::CpuCollection ^ get(); };
public Microsoft.SqlServer.Management.Smo.CpuCollection Cpus { get; }
Public ReadOnly Property Cpus As CpuCollection
Property Value

Examples

This example shows you how to create and display the CPU information for all CPUs on the local instance of SQL Server.

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); foreach (Cpu cpu in dbServer.AffinityInfo.Cpus) { Console.WriteLine("cpu.ID: {0}
" + "cpu.GroupID: {1}
" + "cpu.AffinityMask: {2}
" + "cpu.NumaNodeID: {3}
", cpu.ID, cpu.GroupID, cpu.AffinityMask, cpu.NumaNodeID); } } } }

Powershell

#Create the server.   
$dbServer = new-Object Microsoft.SqlServer.Smo.Server("(local)")  
$dbServer.Refresh()  

Write-Host "Total CPUs:       Microsoft.SqlServer.Smo`n, $dbServer.AffinityInfo.Cpus.Count"  

Foreach ($cpu in $dbServer.AffinityInfo.Cpus)  
{  
   Write-Host $cpu  
}  

Remarks

Access to the Cpus collection is provided though the AffinityInfo member of the Server object.

Applies to