Toolmaking part1 - osinfo

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}

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? :wink:

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

you’re so right
i think i’m going blind or i looked at the screen for to long , either way … not good :smiley:
thank you