The SubString and LastIndexOf methods are used to retrieve the Get-ItemProperty is still used to retrieve the current value to avoid having to parse the string The following example changes the Path entry by removing the path added in the example above. For help with reg.exe, type reg.exe /? at Paths-and not registry entries-which are item properties.Īnother option is to use the Reg.exe command line tool. These parameters refer to registry keys-which are item Set-ItemProperty -Path HKCU:\Environment -Name Path -Value $newpathĪlthough Set-ItemProperty has Filter, Include, and Exclude parameters, theyĬan't be used to filter by property name. $value = Get-ItemProperty -Path HKCU:\Environment -Name Path Use Set-ItemProperty with the specified key, entry name, and value to modify the registry.Add the new value, separating it with a.Retrieve the current value of the Path entry using Get-ItemProperty.Path entry specifies where to find executable files. This example modifies the Path entry under HKEY_CURRENT_USER\Environment. If you want to change a specific entry in a registry key, you can use one of several possibleĪpproaches. Append the property name to the item path with a \ separator: (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DevicePath") You can also use the WshShell COM object to find some registry entries, although this methodĭoesn't work with large binary data or with registry entry names that include characters such asīackslash ( \). HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersionĭevicePath REG_EXPAND_SZ %SystemRoot%\inf To find the DevicePath entry, use reg.exe as shown in the followingĬommand: reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion /v DevicePath For help with reg.exe, type reg.exe /?Īt a command prompt. Paths and not registry entries, which are item properties.Īnother option is to use the reg.exe command line tool. These parameters refer to registry keys, which are item This command returns the standard Windows PowerShell properties as well as the DevicePathĪlthough Get-ItemProperty has Filter, Include, and Exclude parameters, they can'tīe used to filter by property name. PSParentPath : \Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows PSPath : \Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion -Name DevicePath Name parameter to specify the name of the DevicePath entry. Using Get-ItemProperty, use the Path parameter to specify the name of the key, and the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion. This example finds the value of DevicePath in If you want to retrieve a specific entry in a registry key, you can use one of several possibleĪpproaches. The ItemProperty listing for HKLM:\SOFTWARE\Microsoft\Windows\Help using Path expansion works the same as it does within the filesystem, so from this location you can get Specifying a full path: Get-ItemProperty -Path. notation for the current location to list the properties without You can use Set-Location toĬhange to the CurrentVersion registry container first: Set-Location -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersionĪlternatively, you can use the built-in HKLM: PSDrive with Set-Location: Set-Location -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion You can use the *.* notation for referring to the current location. PSPath, PSParentPath, PSChildName, and PSProvider. The Windows PowerShell-related properties for the key are all prefixed with "PS", such as PSParentPath : \Registry::HKEY_LOCAL_MACHINE\SOFTWA PSPath : \Registry::HKEY_LOCAL_MACHINE\SOFTWA SM_ConfigureProgramsName : Set Program Access and Defaults ProgramFilesDir (x86) : C:\Program Files (x86)ĬommonFilesDir (x86) : C:\Program Files (x86)\Common FilesĬommonW6432Dir : C:\Program Files\Common Files To view the registry entries in a more readable form, use Get-ItemProperty: Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersionĬommonFilesDir : C:\Program Files\Common Files List: Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion | Theįollowing command selects the Property property and expands the items so that they're displayed in a Property with the generic name of "Property" that's a list of registry entries in the key. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion, use Get-Item. For example, to see the names of the entries in the registry key There are many different ways to examine registry entries. Take a slightly different approach when working with them. This sample only applies to Windows platforms.īecause registry entries are properties of keys and, as such, can't be directly browsed, we need to
0 Comments
Leave a Reply. |