LoginSignup
7
8

More than 5 years have passed since last update.

PowerShellでWindowsPCの端末情報(OSバージョン/モデル型番/シリアル番号など)を取得する

Posted at

WindowsPC端末の情報(OSバージョン/モデル型番/シリアル番号など)を取得する処理をPowerShellで書いたので貼っておく。
情報源は WMI経由で取得できる Win32_OperatingSystem/Win32_ComputerSystem/Win32_BIOS あたり。
他にも足りないものあるかもだけど、とりあえずPC端末管理目的ならこれぐらい取っておけば十分かなと。

function Check-SystemInfo{
    $systemInfo = @{}
    # Date
    # チェック実行日時
    $systemInfo["CheckDateTime"] = Get-Date -Format "yyyyMMdd_HHmmss"

    # Environment
    # ホスト名
    $systemInfo["EnvComputername"] = $env:computername
    # ユーザ名
    $systemInfo["EnvUsername"] = $env:username

    # OS
    $os = Get-WMIObject -Namespace "root/CIMV2" -Query "SELECT * FROM Win32_OperatingSystem"
    # OS名称
    $systemInfo["OsCaption"] = $os.Caption
    # OSバージョン
    $systemInfo["OsVersion"] = $os.Version
    # OSアーキテクチャ(ビット数)
    $systemInfo["OsArchitecture"] = $os.OSArchitecture
    # OSインストール日
    $systemInfo["OsInstallDate"] = $os.InstallDate
    # 最終起動日時
    $systemInfo["OsLastBootUpTime"] = $os.LastBootUpTime

    # Computer
    $computer = Get-WMIObject -Namespace "root/CIMV2" -Query "SELECT * FROM Win32_ComputerSystem"
    # メーカー
    $systemInfo["ComputerManufacturer"] = $computer.Manufacturer
    # モデル
    $systemInfo["ComputerModel"] = $computer.Model
    # Windowsドメイン(ワークグループ)
    $systemInfo["ComputerDomain"] = $computer.Domain
    # 所有者(通常PCを初期セットアップ時に作成したアカウント名が表示される)
    $systemInfo["PrimaryOwnerName"] = $computer.PrimaryOwnerName

    # BIOS
    $bios = Get-WMIObject -Namespace "root/CIMV2" -Query "SELECT * FROM Win32_BIOS"
    # シリアル番号(ユーザ名とコンピュータ名は利用者が指定できるので端末の一意性を特定する情報)
    # VirtualBoxだと0が出力されてる
    $systemInfo["BiosSerialNumber"] = $bios.SerialNumber

    return $systemInfo
}
7
8
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
7
8