Powershell script to find applications that come with their own Java versions

佐手、 提交于 2021-02-05 08:26:27

问题


I am looking for a way to find out from all installed applications, one that comes with its own java version. There are scripts online to see the version installed on PCs but not the one to get the applications that uses Java and what versions of java they have.

I found something close with using system explorer where I can view all running processes but what i want is a script that can find such applications with the java versions they use and then export the result as csv file or something.

Get-Childitem –Path c:\ -Include java.exe -Recurse -ErrorAction SilentlyContinue | select FullName

I have also written a one line code that kind of shows few applications (2 in my case) but I know there are more.


回答1:


Some java.exe files may be buried inside hidden folders. To also list those, add the -Force switch. Something like this:

Get-Childitem -Path 'C:\' -Filter 'java.exe' -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object {
    [PsCustomObject]@{
        'Path'       = $_.FullName
        'Version'    = (Get-Command java | Select-Object -ExpandProperty Version)
        'ExeVersion' = $_.VersionInfo.ProductVersion 
    }
}


来源:https://stackoverflow.com/questions/58375756/powershell-script-to-find-applications-that-come-with-their-own-java-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!