Skip to content

Instantly share code, notes, and snippets.

@mwjcomputing
Created March 1, 2013 20:10
Show Gist options
  • Select an option

  • Save mwjcomputing/5067386 to your computer and use it in GitHub Desktop.

Select an option

Save mwjcomputing/5067386 to your computer and use it in GitHub Desktop.
Gets information on the version of Oracle Java that is installed.
function Get-OracleJavaVersion {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline=$true)]
[alias("Computer")]
[string]$ComputerName = "$env:COMPUTERNAME"
)
begin{
## Create WMI filter.
$filter = "Name Like 'Java %' AND Vendor='Oracle'"
## Make new object
$obj = New-Object PSObject
}
process{
## Collect information about Java from WMI.
$javaInfo = Get-WmiObject -Class 'Win32_Product' -Filter $filter -ComputerName $ComputerName
## Add information to object
Add-Member -InputObject $obj -MemberType NoteProperty -Name Computer -Value $computerName
Add-Member -InputObject $obj -MemberType NoteProperty -Name Name -Value $javaInfo.Name
Add-Member -InputObject $obj -MemberType NoteProperty -Name Vendor -Value $javaInfo.Vendor
Add-Member -InputObject $obj -MemberType NoteProperty -Name Version -Value $javaInfo.Version
}
end{
## Output object
Write-Output -InputObject $obj
}
<#
.SYNOPSIS
Gets version information about the version of Oracle Java that is installed.
.DESCRIPTION
Uses WMI to get the version information about the version of Oracle Java that is installed.
.PARAMETER ComputerName
The name of the computer to check
.EXAMPLE
PS> Get-OracleJavaVersion -ComputerName DC1
.INPUTS
System.String
.OUTPUTS
PSObject
.NOTES
Written by: Matt Johnson
Email: mwjcomputing [at] gmail [dot] com
.LINK
www.mwjcomputing.com
.LINK
github.com/mwjcomputing
#>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment