LoginSignup
6
6

More than 3 years have passed since last update.

Powershellでブラウザのバージョンを取得

Last updated at Posted at 2019-11-27
  • 2019/01/16
    2019/01/15にリリースされたChromiumベースのEdgeの場合のバージョン取得方法を追記。

Google Chrome

(get-item ($env:SystemDrive + "\Program Files (x86)\Google\Chrome\Application\chrome.exe")).VersionInfo.FileVersion

Mozilla Firefox

(get-item ($env:SystemDrive + "\Program Files\Mozilla Firefox\firefox.exe")).VersionInfo.FileVersion

Internet Explorer

IE11のみ動作確認。
バージョン、更新バージョン、KB番号を表示。

(Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Internet Explorer" -Name svcVersion) + "(Update: " + (Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Internet Explorer" -Name svcUpdateVersion) + "(" + (Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Internet Explorer" -Name svcKBNumber) + "))"

Microsoft Edge (Version 44以前)

Version 44(Chromium版になる前)以前の場合

Get-AppxPackage -Name Microsoft.MicrosoftEdge | Foreach Version

Microsoft Edge (Version 79以降)

Version 79(Chromium版)以降の場合

(get-item ($env:SystemDrive + "\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")).VersionInfo.FileVersion

おまけ スクリプト

各ブラウザのバージョンを取得して出力し、カレントディレクトリに同内容を出力したログファイルを作成します。
所定のパスにexeがない場合はインストールされていないと見なして"N/A"と出力します。
※ 実行はご自身の責任で行ってください。
※ 記法が正しくない、または効率的でない可能性が多分にあります。

$CHROME_PATH = $env:SystemDrive + "\Program Files (x86)\Google\Chrome\Application\chrome.exe"
$FIREFOX_PATH = $env:SystemDrive + "\Program Files\Mozilla Firefox\firefox.exe"
$IE11_PATH = $env:SystemDrive + "\Program Files\internet explorer\iexplore.exe"
$MSEDGE_PATH = $env:SystemDrive + "\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
$MSEDGEOLD_PATH = $env:SystemDrive + "\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe"

$CHROME_VER = "Google Chrome: "
$FIREFOX_VER = "Mozilla Firefox: "
$IE11_VER = "Internet Explorer: "
$MSEDGE_VER = "Microsoft Edge: "
$MSEDGEOLD_VER = "Microsoft Edge(old): "

if (Test-Path $CHROME_PATH) {
    $CHROME_VER = $CHROME_VER + (get-item $CHROME_PATH).VersionInfo.FileVersion
} else {
    $CHROME_VER = $CHROME_VER + "N/A"
}
if (Test-Path $FIREFOX_PATH) {
    $FIREFOX_VER = $FIREFOX_VER + (get-item $FIREFOX_PATH).VersionInfo.FileVersion
} else {
    $FIREFOX_VER = $FIREFOX_VER + "N/A"
}
if (Test-Path $IE11_PATH) {
    $IE11_VER = $IE11_VER + (Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Internet Explorer" -Name svcVersion) + "(Update: " + (Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Internet Explorer" -Name svcUpdateVersion) + "(" + (Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Internet Explorer" -Name svcKBNumber) + "))"
} else {
    $IE11_VER = $IE11_VER + "N/A"
}
if (Test-Path $MSEDGE_PATH) {
    $MSEDGE_VER = $MSEDGE_VER + (get-item $MSEDGE_PATH).VersionInfo.FileVersion
} else {
    $MSEDGE_VER = $MSEDGE_VER + "N/A"
}
if (Test-Path $MSEDGEOLD_PATH) {
    $MSEDGEOLD_VER = $MSEDGEOLD_VER + (Get-AppxPackage -Name Microsoft.MicrosoftEdge | Foreach Version)
} else {
    $MSEDGEOLD_VER = $MSEDGEOLD_VER + "N/A"
}

Write-Host $CHROME_VER
Write-Host $FIREFOX_VER
Write-Host $IE11_VER
Write-Host $MSEDGE_VER
Write-Host $MSEDGEOLD_VER

$NowTime = Get-Date
$LogPath = ".\CheckBrowserVer.log"
Add-Content $LogPath $NowTime
Add-Content $LogPath $CHROME_VER
Add-Content $LogPath $FIREFOX_VER
Add-Content $LogPath $IE11_VER
Add-Content $LogPath $MSEDGE_VER
Add-Content $LogPath $MSEDGEOLD_VER
Add-Content $LogPath "--------"
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6