NAME

Set-RegDefault

SYNOPSIS

Sets the default value (REG_SZ) of the registry key on local or remote computers.

SYNTAX

Set-RegDefault [[-ComputerName] <>] [[-Hive] <>] [-Key] <> [-Data] <> [-Ping] [-Force] [-View] [-PassThru] [-WhatIf] [-Confirm] [<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

 

-Data <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? 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

 

-Force <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

 

-PassThru <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

 

-WhatIf <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  
Accept pipeline input? false
Accept wildcard characters? false

 

-Confirm <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  
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\MyCompany"

"SERVER1","SERVER2","SERVER3" | Set-RegDefault -Key $Key -Data MyDefaultValue -Ping -PassThru -Force

ComputerName Hive Key Value Data Type
------------ ---- --- ----- ---- ----
SERVER1 LocalMachine SOFTWARE\MyCompany (Default) MyDefaultValue String
SERVER2 LocalMachine SOFTWARE\MyCompany (Default) MyDefaultValue String
SERVER3 LocalMachine SOFTWARE\MyCompany (Default) MyDefaultValue String

Description
-----------
Set the reg default value of the SOFTWARE\MyCompany subkey on three remote computers local machine hive (HKLM) .
Ping each server before setting the value and use -PassThru to get the objects back. Use Force to override confirmations.

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

C:\PS>[Environment]::Is64BitProcess

False

PS> Set-RegDefault -Hive LocalMachine -Key SOFTWARE\MyKey -ComputerName Server1 -Data NewValue -View Registry64 -Force -PassThru

ComputerName Hive Key Value Data Type
------------ ---- --- ----- ---- ----
Server1 LocalMachine SOFTWARE\MyKey (Default) NewValue String


Description
-----------
This command is using an elevated 32-bit instance of Windows PowerShell to set values on
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.

RELATED LINKS

http://psrr.codeplex.com
Get-RegDefault
Get-RegValue

Last edited Jun 11, 2012 at 1:37 PM by Shay, version 2

Comments

No comments yet.