Partager via


Propriété AffinityInfo.Cpus

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

Espace de noms :  Microsoft.SqlServer.Management.Smo
Assembly :  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Syntaxe

'Déclaration
Public ReadOnly Property Cpus As CpuCollection 
    Get
'Utilisation
Dim instance As AffinityInfo 
Dim value As CpuCollection 

value = instance.Cpus
public CpuCollection Cpus { get; }
public:
property CpuCollection^ Cpus {
    CpuCollection^ get ();
}
member Cpus : CpuCollection
function get Cpus () : CpuCollection

Valeur de propriété

Type : Microsoft.SqlServer.Management.Smo.CpuCollection
Returns a CPUCollection.

Notes

Access to the Cpus collection is provided though the [T:Microsoft.SqlServer.Management.Smo.AffinityInfo.] member of the Server object.

Exemples

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}\n", dbServer.AffinityInfo.Cpus.Count);

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

Voir aussi

Référence

AffinityInfo Classe

Espace de noms Microsoft.SqlServer.Management.Smo