Skip to content

Update-Object

SYNOPSIS

Recursively updates a hashtable or custom object with new values

SYNTAX

Update-Object [-UpdateObject] <Object> -InputObject <Object> [-ImportantInputProperties <String[]>] [-WhatIf]
 [-Confirm] [<CommonParameters>]

DESCRIPTION

Updates the InputObject with data from the update object, updating or adding values.

EXAMPLES

EXAMPLE 1

Update-Object -Input @{
   One = "Un"
   Two = "Dos"
} -Update @{
   One = "Uno"
   Three = "Tres"
}

Updates the InputObject with the values in the UpdateObject, will return the following object:

@{ One = "Uno" Two = "Dos" Three = "Tres" }

PARAMETERS

-UpdateObject

The object (or hashtable) with properties (or keys) to overwrite the InputObject

Type: System.Object
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InputObject

This base object (or hashtable) will be updated and overwritten by the UpdateObject

Type: System.Object
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-ImportantInputProperties

A list of values which (if found on InputObject) should not be updated from UpdateObject

Type: System.String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

Back to top