none
Number of virtual processor. RRS feed

  • Question

  • Hi friends 

    is there any script to find the count of virtual processor in each socket.

    i have created below script to find the same .

    please suggest whether  i can continue with below script.

    $proccessorcount = (Get-WmiObject -class Win32_Processor).numberoflogicalprocessors
    $sum=0
    foreach($pcount in $proccessorcount)
    {
    $sum+=$pcount
    }

    write-host "virtual processor count : $sum"


    JITHIN.R

    Thursday, November 15, 2018 4:07 PM

Answers

  • Does this help?
    $CPUList = @(Get-WmiObject -class Win32_Processor)
    
    [PSCustomObject]@{
        SocketCount = $CPUList.Count
        NumberOfCoresPerSocket = $CPUList[0].NumberOfCores
        NumberOfLogicalProcessorsPerSocket = $CPUList[0].NumberOfLogicalProcessors
        NumberOfCoresSum = $CPUList[0].NumberOfCores  * $CPUList.Count
        NumberOfLogicalProcessorsSum = $CPUList[0].NumberOfLogicalProcessors * $CPUList.Count
    }


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Friday, November 16, 2018 7:19 AM corrected code
    • Marked as answer by JITHUTTEN JITHIN Thursday, November 22, 2018 10:03 AM
    Thursday, November 15, 2018 8:36 PM

All replies

  • Does this help?
    $CPUList = @(Get-WmiObject -class Win32_Processor)
    
    [PSCustomObject]@{
        SocketCount = $CPUList.Count
        NumberOfCoresPerSocket = $CPUList[0].NumberOfCores
        NumberOfLogicalProcessorsPerSocket = $CPUList[0].NumberOfLogicalProcessors
        NumberOfCoresSum = $CPUList[0].NumberOfCores  * $CPUList.Count
        NumberOfLogicalProcessorsSum = $CPUList[0].NumberOfLogicalProcessors * $CPUList.Count
    }


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Friday, November 16, 2018 7:19 AM corrected code
    • Marked as answer by JITHUTTEN JITHIN Thursday, November 22, 2018 10:03 AM
    Thursday, November 15, 2018 8:36 PM
  • Hi Friend,

    I'm getting below output.

    ###############################################

    PS C:\Users\jrayaroc> $CPUList = Get-WmiObject -class Win32_Processor
    PS C:\Users\jrayaroc>
    PS C:\Users\jrayaroc> [PSCustomObject]@{
         SocketCount = $CPUList.Count
         NumberOfCoresPerSocket = $CPUList[0].NumberOfCores
         NumberOfLogicalProcessorsPerSocket = $CPUList[0].NumberOfLogicalProcessors
         NumberOfCoresSum = $CPUList[0].NumberOfCores  * $CPUList.Count
         NumberOfLogicalProcessorsSum = $CPUList[0].NumberOfLogicalProcessors * $CPUList.Count



    SocketCount                        :
    NumberOfCoresPerSocket             :
    NumberOfLogicalProcessorsPerSocket :
    NumberOfCoresSum                   :
    NumberOfLogicalProcessorsSum       :

    #########################################################


    JITHIN.R

    Friday, November 16, 2018 3:07 AM
  • So you obviously have only one processor in one socket. Your question sounded like you're asking for servers with more than one socket.

    I updated my code. And I reccomend for you to urgently start to learn the very basics of Powershell. With that you would be able to debug scripts by yourself.

    And please format your code as code here in the forum. Use the code posting tool provided on the tool bar of the post editor. Thanks


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''



    • Edited by BOfH-666 Friday, November 16, 2018 7:21 AM
    Friday, November 16, 2018 7:19 AM
  • $CPUList = @(Get-WmiObject -class Win32_Processor)
    
    [PSCustomObject]@{
        SocketCount = $CPUList.Count
        NumberOfCoresPerSocket = $CPUList[0].NumberOfCores
        NumberOfLogicalProcessorsPerSocket = $CPUList[0].NumberOfLogicalProcessors
        NumberOfCoresSum = $CPUList[0].NumberOfCores  * $CPUList.Count
        NumberOfLogicalProcessorsSum = $CPUList[0].NumberOfLogicalProcessors * $CPUList.Count
    }
    
    
    
    SocketCount                        : 2
    NumberOfCoresPerSocket             : 2
    NumberOfLogicalProcessorsPerSocket : 2
    NumberOfCoresSum                   : 4
    NumberOfLogicalProcessorsSum       : 4
    
    ####################################################
    

    Hi this code worked thank you...

    and thank you for your suggestion


    JITHIN.R

    Thursday, November 22, 2018 10:00 AM
  • Cool.

    Just because I'm curious - what kind of processors do you have?


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Thursday, November 22, 2018 10:09 AM