Win32_Processor and SystemName

Discussion in 'Scripting' started by joe, Apr 15, 2008.

  1. joe

    joe Guest

    How do I print out only the SystemName from Win32_Processor or
    Win32_computerSystem
     
    joe, Apr 15, 2008
    #1
    1. Advertisements

  2. Try this:
    Set objCompSet =
    GetObject("winmgmts:{impersonationLevel=impersonate}!//./root/cimv2").ExecQuery("select
    Name from Win32_ComputerSystem")
    For Each objDetail In objCompSet
    WScript.echo objDetail.Name
    Next
     
    Pegasus \(MVP\), Apr 15, 2008
    #2
    1. Advertisements

  3. joe

    joe Guest

    Hi

    What about the "system name" variable

    I want to output

    System Name

    hostname

    under one column in excel
     
    joe, Apr 16, 2008
    #3
  4. I'm not aware of a "System Name" variable. Where does
    it occur?
     
    Pegasus \(MVP\), Apr 16, 2008
    #4
  5. joe

    joe Guest

    when i run

    For Each objProperty In objClass.Properties_
    objSheet.Cells (intRow, intColumn) = objProperty.Name
    intColumn = intColumn + 1
    Next


    There is a column called System Name

    I want to output only this
     
    joe, Apr 17, 2008
    #5
  6. Can't tell - you're not giving us any definition of the object
    objClass.Properties_.
     
    Pegasus \(MVP\), Apr 17, 2008
    #6
  7. joe

    joe Guest

    Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Processor")
     
    joe, Apr 18, 2008
    #7
  8. joe

    Allan Guest

    It should pull it. Here is an example:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
    For Each objProcessor in colProcessors
    WScript.Echo " SystemName: " & objProcessor.SystemName
    Next

    If you want more information, go to:
    http://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx

    Thanks,
    Allan
     
    Allan, May 22, 2008
    #8
  9. hey all, I just wrote the below script to do this, although here's a one-liner as well:

    PS C:\temp> gwmi Win32_Processor | Format-table SystemName,Name,NumberOfCores -auto

    SystemName Name NumberOfCores
    ---------- --- -------
    Server-01 Intel(R) Xeon(R)CPU X5460 @ 3.16GHz 4
    Server-01 Intel(R) Xeon(R)CPU X5460 @ 3.16GHz 4


    Script
    =================================================

    $strComputer = (hostname)
    $OF = "C:\temp\CPUAudit.txt"
    $Arr = @()
    Write-Host Begin Processor Survey -ForegroundColor Yellow
    Foreach ($Server in $strComputer) {
    $Counter = 0
    Write-Host Querying Processor information on $Server -ForegroundColor Magenta
    $colItems = get-wmiobject -class Win32_Processor -computername $Server
    foreach($objItem in $colItems){
    $temp = New-Object system.Object
    $temp | Add-Member -MemberType NoteProperty -Name "MachineName" -Value $objItem.SystemName
    $temp | Add-Member -MemberType NoteProperty -Name "Description" -Value $objItem.Caption
    $temp | Add-Member -MemberType NoteProperty -Name "CPU #" -Value $objItem.Name
    $temp | Add-Member -MemberType NoteProperty -Name "# Cores" -Value $objItem.NumberOfCores
    $Arr += $temp
    $Counter++
    }
    Write-Host Query returned $Counter Procs on $Server
    Write-Host =================
    }
    Write-host Processed $Arr.count Servers -ForegroundColor Green
    $Arr | FT -autosize | Out-File $OF -Append
     
    Stefan Herman, Nov 19, 2011
    #9

  10. < snip >

    You only too 3.5 years.
     
    David H. Lipman, Nov 19, 2011
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.