PoshCode Archive  Artifact [15a5272254]

Artifact 15a5272254383cfdbb04fdaeb2cb1091b8e60426b65e7cfbb206d7daa0b4b58d:

  • File Get-HPAgentVersion.ps1 — part of check-in [1437546658] at 2018-06-10 13:34:33 on branch trunk — The Get-HPAgentVersion function gets the HP PSP/SPP version. (user: Chad Miller size: 1572)

# encoding: ascii
# api: powershell
# title: Get-HPAgentVersion
# description: The Get-HPAgentVersion function gets the HP PSP/SPP version.
# version: 1.0
# type: script
# author: Chad Miller
# license: CC0
# function: Get-HPAgentVersion
# x-poshcode-id: 4010
# x-archived: 2013-03-21T05:48:12
# x-published: 2013-03-13T13:57:00
#
#
#######################
<#
.SYNOPSIS
Gets HP PSP/SPP Agent Version
.DESCRIPTION
The Get-HPAgentVersion function gets the HP PSP/SPP version.
.EXAMPLE
Get-HPAgentVersion "Z002"
This command gets information for computername Z002.
.EXAMPLE
Get-Content ./servers.txt | Get-HPAgentVersion
This command gets information for a list of servers stored in servers.txt.
.EXAMPLE
Get-HPAgentVersion (get-content ./servers.txt)
This command gets information for a list of servers stored in servers.txt.
.NOTES 
Version History 
v1.0   - Chad Miller - Initial release 
#>
function Get-HPAgentVersion
{
    [CmdletBinding()]
    param(
    [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [ValidateNotNullorEmpty()]
    [string[]]$ComputerName
    )
    BEGIN {}
    PROCESS {
        foreach ($computer in $computername) {
            Get-WMIObject -ComputerName $computer -Query "SELECT * FROM CIM_DataFile WHERE Drive ='C:' AND Path='\\WINDOWS\\system32\\CpqMgmt\\' AND FileName='agentver' AND Extension='dll'"  |
            Select CSName, Version, @{n='OS';e={(gwmi win32_operatingsystem -ComputerName $_.CSName).Version}}
        }
    }
    END {}
}