Public/Query-ComputerInfo.ps1

function Query-ComputerInfo {

    <#
    .SYNOPSIS
        Query basic system information.
 
    .DESCRIPTION
        Query basic system information about the target computer.
 
    .NOTES
        Author: Greg Powers
    #>


    [CmdletBinding()]
    param (
        # ComputerName --
        [Parameter(
            Position=0,
            Mandatory=$true,
            ValueFromPipeline=$true
        )]
        [System.Object]
        $ComputerName
    )
    
    begin {
    }
    
    process {
        foreach ($Computer in $ComputerName) {
            $CIMSession = New-CimSession -ComputerName $Computer
            $ComputerInfo = Get-CimInstance -CimSession $CIMSession -ClassName Win32_OperatingSystem
            Remove-CimSession -CimSession $CIMSession
            [PSCustomObject]@{
                Computer = $ComputerInfo.CSName
                OperatingSystem = $ComputerInfo.Caption
                OSVer = $ComputerInfo.Version
                WinDir = $ComputerInfo.WindowsDirectory
            }
        }
    }
    
    end {
    }
}