The following example shows how you can query the registry values of the current
key or of another key:
Get-ItemProperty .
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion
You can see the results of running Get-ItemProperty . while in HKLM:\Software\
Microsoft\Windows\CurrentVersion\run in Figure 13-6. Since Get-ItemProperty is
not specifically designed just for registry keys, it shows additional metadata regarding the
object you are running it against. In this case, it shows the path to the registry key, the path
to its parent, the key name, the ???drive??? (hive) of the key, the provider, and finally a list of
values in the Run key. Since I have only one entry in my Run key, namely MyApp, pointing
to C:\Apps\MyApp.exe, it gets displayed after the general object information.
Only HKEY_LOCAL_MACHINE (HKLM) and HKEY_CURRENT_USER (HKCU)
are accessible quickly using the CD HKLM: or CD HKCU: shortcut. To get to other hives
such as HKEY_CLASSES_ROOT or HKEY_USERS, you need to connect directly to the
PowerShell Registry Provider. It??™s not that difficult to do. The following command sequence
finds out which application opens up .TXT files:
CD REGISTRY::
CD HKEY_CLASSES_ROOT\.txt\shellnew
Get-ItemProperty .
454 Microsoft Windows Server 2008 Administration
You could also put it all on one line:
Get-ItemProperty REGISTRY::HKEY_CLASSES_ROOT\.txt\shellnew
TIP Typing Get-ItemProperty over and over gets old pretty quickly, so Microsoft has predefined
an alias for this cmdlet.
Pages:
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486