1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PCの基本スペックをラベル印刷するためにテキストで取得する

Posted at

Label

Powershellで

Write-Host "OS:`t" (Get-WmiObject Win32_OperatingSystem).Caption
Write-Host "CPU:`t" (Get-WmiObject Win32_Processor).Name
Write-Host "Memory:`t" ([System.Convert]::ToInt32((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory/(1024*1024*1024))) "GB"
Write-Host "GPU:`t" (Get-WmiObject Win32_VideoController).Name
pause
  • Write-Host でそのあとに続く引数をテキストでPowerShellに出力
  • Get-WmiObject でオブジェクトを得る
  • メモリについては Byte から GB に変換した上で ToInt32 で丸める
  • `t はタブ

↑のファイルを .ps1 フォーマットで作成し、右クリックして Run with PowerShell で実行できますが、権限の関係でできないかもしれません。
その場合はセミコロン区切りで1行にして PowerShell にコピペして実行が楽だと思います。

Write-Host "OS:`t" (Get-WmiObject Win32_OperatingSystem).Caption;Write-Host "CPU:`t" (Get-WmiObject Win32_Processor).Name;Write-Host "Memory:`t" ([System.Convert]::ToInt32((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory/(1024*1024*1024))) "GB";Write-Host "GPU:`t" (Get-WmiObject Win32_VideoController).Name

実行すると次のようなテキストが得られます。

OS:      Microsoft Windows 10 Home
CPU:     Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Memory:  16 GB
GPU:     NVIDIA GeForce GTX 1080 Ti

これをどうにかしてテプラで印刷します。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?