17
20

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.

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")
    1. サブキー一覧
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion").GetValueNames()
    1. サブキー名を指定 Registry の Type 取得
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion").GetValueKind("DevicePath")
    1. サブキー名を指定して Registryの Value 取得
(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion").GetValue("DevicePath")
    1. 特定のキー以下のサブキーのType全取得
$key=(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion"); $key.GetValueNames()|ForEach-Object{ $key.GetValueKind($_) }
    1. 特定のキー以下のサブキーのValue全取得
$key=(Get-Item -Path "Registry::HKLM\Software\Microsoft\Windows\CurrentVersion"); $key.GetValueNames()|ForEach-Object{ $key.GetValue($_) }
    1. 特定のキー以下のサブキーの名前, 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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?