首页 > 解决方案 > 如何使用 Powershell 获取 exe 应用程序详细信息

问题描述

我是 Powershell 新手,正在尝试获取 Outlook 文件版本详细信息。

get-itemproperty 'C:\program File (x86)\Microsoft Office\office15\outlook.exe' | 格式列表

这是我使用的命令,但会弹出找不到路径错误。

outlook.exe 路径:C:\program File (x86)\Microsoft Office\office15\outlook.exe

我需要的值 文件版本和产品名称值是我想要的

标签: powershellsystem-administration

解决方案


Outlook的版本是16,所以路径不一样...但是,下面应该为您动态找到安装位置,因此无关紧要。

#Set the Reg Key to find
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE\'

#Get the Reg Key Property
$outlookExePath = (Get-ItemProperty $key).'(default)'

#Use the Reg Key Property to get the FileInfo 
$OutlookExe = get-item $outlookExePath

#Output the File Info Properties as required    
$OutlookExe.VersionInfo.ProductVersion
$OutlookExe.VersionInfo.ProductName

#Or output selected properties together
$OutlookExe.VersionInfo|Select-Object -Property ProductName,ProductVersion

推荐阅读