Toolmaking part1 - osinfo

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Alexandru Alexandru 3 weeks ago.

  • Author
    Posts
  • #57872
    Profile photo of Alexandru
    Alexandru
    Participant

    Hi, i just watched on youtube part1 of Don's toolmaking videos and i can't understand why this piece of script it's giving me different output than did for him

    param([string[]]$ComputerName)
    
    foreach ($computer in $ComputerName) {
    
    $os = Get-CimInstance -ComputerName $ComputerName -ClassName win32_operatingsystem
    $cs = Get-CimInstance -ComputerName $ComputerName -ClassName win32_computersystem
    
    $properties = @{ComputerName = $computer
                    SPVersion = $os.ServicePackMajorVersion
                    OSVersion  = $os.Version
                    Model = $cs.Model
                    Mfgr = $cs.Manufacturer
                    }
     
        $obj = New-Object -TypeName psobject -Property $properties
        Write-Output $obj
    }

    output

    .\get-osinfo.ps1 -ComputerName dc,wsus
    
    
    Mfgr         : {Microsoft Corporation, Supermicro}
    ComputerName : dc
    SPVersion    : {0, 1}
    Model        : {Virtual Machine, P8SCT}
    OSVersion    : {6.3.9600, 6.1.7601}
    
    Mfgr         : {Microsoft Corporation, Supermicro}
    ComputerName : wsus
    SPVersion    : {0, 1}
    Model        : {Virtual Machine, P8SCT}
    OSVersion    : {6.3.9600, 6.1.7601}
  • #57874
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    your version:

    $os = Get-CimInstance -ComputerName $ComputerName -ClassName win32_operatingsystem
    $cs = Get-CimInstance -ComputerName $ComputerName -ClassName win32_computersystem

    how I guess it should be:

    $os = Get-CimInstance -ComputerName $Computer -ClassName win32_operatingsystem
    $cs = Get-CimInstance -ComputerName $Computer -ClassName win32_computersystem

    right? 😉

    • #57878
      Profile photo of Alexandru
      Alexandru
      Participant

      you're so right
      i think i'm going blind or i looked at the screen for to long , either way ... not good 😀
      thank you

  • #57877
    Profile photo of Alex
    Alex
    Participant

    What is the output you are expecting? Looks like what I would have expected.

You must be logged in to reply to this topic.