LoginSignup
17
20

More than 5 years have passed since last update.

PowerShell だけで レジストリの値とその種類を取得したい

Last updated at Posted at 2016-08-04

ネタ元:http://powershell.com/cs/blogs/tips/archive/2015/04/15/getting-registry-values-and-value-types.aspx

  • 1. キーが存在するか
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion")
  • 2. サブキー一覧
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion").GetValueNames()
  • 3. サブキー名を指定 Registry の Type 取得
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion").GetValueKind("DevicePath")
  • 4. サブキー名を指定して Registryの Value 取得
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion").GetValue("DevicePath")
  • 5. 特定のキー以下のサブキーのType全取得
$key=(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion"); $key.GetValueNames()|ForEach-Object{ $key.GetValueKind($_) }
  • 6. 特定のキー以下のサブキーのValue全取得
$key=(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion"); $key.GetValueNames()|ForEach-Object{ $key.GetValue($_) }
  • 7. 特定のキー以下のサブキーの名前, Type, Value をいい感じに出す
$key=(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion"); $key.GetValueNames()|ForEach-Object{$name=$_; $rv = (1 | Select-Object -Property Name, Type, Value); $rv.Name= $name; $rv.Type=$key.GetValueKind($_);$rv.Value=$key.GetValue($_); $rv }

Type の表示は Microsoft.Win32.RegistryValueKind がでているようなので
https://msdn.microsoft.com/ja-jp/library/microsoft.win32.registryvaluekind%28v=vs.110%29.aspx

http://www.atmarkit.co.jp/fdotnet/dotnettips/478registryvaluekind/registryvaluekind.html を確認してください。

17
20
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
17
20