NAME

Get-RegExpandString

SYNOPSIS

Retrieves a null-terminated string that contains unexpanded references to environment variables (REG_EXPAND_SZ) from local or remote computers.

SYNTAX

Get-RegExpandString [[-ComputerName] <>] [[-Hive] <>] [-Key] <> [-Value] <> [-ExpandEnvironmentNames] [-View] [-Ping] [<CommonParameters>]

DESCRIPTION

 

PARAMETERS

-ComputerName <String[]>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? false
Position? 1
Default value $env:COMPUTERNAME
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

 

-Hive <String>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? false
Position? 2
Default value LocalMachine
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

 

-Key <String>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? true
Position? 3
Default value  
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

 

-Value <String>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? true
Position? 4
Default value  
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

 

-ExpandEnvironmentNames <SwitchParameter>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false

 

-View <RegistryView>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? false
Position? named
Default value Default
Accept pipeline input? false
Accept wildcard characters? false

 

-Ping <SwitchParameter>

Adds a new member even the object has a custom member with the same name. You cannot use the Force parameter to replace a standard member of a type.

Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false

 

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS

 

OUTPUTS

PSFanatic.Registry.RegistryValue (PSCustomObject)

NOTES

Author: Shay Levy
Blog : http://PowerShay.com

EXAMPLES

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$Key = "SOFTWARE\Microsoft\Windows\CurrentVersion"

Get-RegExpandString -Key $Key -Value ProgramFilesPath

ComputerName Hive Key Value Data Type
------------ ---- --- ----- ---- ----
COMPUTER1 LocalMachine SOFTWARE\Microsof... ProgramFilesPath %ProgramFiles% ExpandString


Description
-----------
The command gets the registry ProgramFilesPath ExpandString value from the local computer.
The returned value contains unexpanded references to environment variables.

-------------------------- EXAMPLE 2 --------------------------

C:\PS>[Environment]::Is64BitProcess

False

PS> Get-RegExpandString -Key SOFTWARE\MyKey -ComputerName Server1 -View Registry64 -Value 64ExpandString

ComputerName Hive Key Value Data Type
------------ ---- --- ----- ---- ----
Server1 LocalMachine SOFTWARE\MyKey 64ExpandString %windir% ExpandString


Description
-----------
This command is using an elevated 32-bit instance of Windows PowerShell to read values from
a 64-bit registry section of a remote 64-bit server. First we verify that the current console
is a 32-bit instance by using the Is64BitProcess system environment variable.

Connecting to the 64-bit section of the remote server registry is done using the View
parameter.

-------------------------- EXAMPLE 3 --------------------------

C:\PS>Get-RegExpandString -Key $Key -Value ProgramFilesPath -ComputerName SERVER1,SERVER2,SERVER3 -ExpandEnvironmentNames -Ping

ComputerName Hive Key Value Data Type
------------ ---- --- ----- ---- ----
SERVER1 LocalMachine SOFTWARE\Microsof... ProgramFilesPath C:\Program Files ExpandString
SERVER2 LocalMachine SOFTWARE\Microsof... ProgramFilesPath C:\Program Files ExpandString
SERVER3 LocalMachine SOFTWARE\Microsof... ProgramFilesPath C:\Program Files ExpandString


Description
-----------
The command gets the registry ProgramFilesPath ExpandString value from three remote computers.
When the ExpandEnvironmentNames Switch parameter is used, the data of the value is expnaded based on the environment variables data from the local environment.
When the Switch parameter Ping is specified the command issues a ping test to each computer.
If the computer is not responding to the ping request a warning message is written to the console and the computer is not processed.

RELATED LINKS

http://psrr.codeplex.com
Set-RegExpandString
Get-RegValue
Remove-RegValue
Test-RegValue

Last edited Jun 11, 2012 at 12:27 PM by Shay, version 2

Comments

No comments yet.