Set-HPUEFIVariable



Summary

Sets a UEFI variable value

Syntax

Set-HPUEFIVariable [-Name] <String> [-Value] <Object> [-Namespace] <String> [[-Attributes] {VARIABLE_ATTRIBUTE_NON_VOLATILE | VARIABLE_ATTRIBUTE_BOOTSERVICE_ACCESS | VARIABLE_ATTRIBUTE_RUNTIME_ACCESS | VARIABLE_ATTRIBUTE_HARDWARE_ERROR_RECORD | VARIABLE_ATTRIBUTE_AUTHENTICATED_WRITE_ACCESS | VARIABLE_ATTRIBUTE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | VARIABLE_ATTRIBUTE_APPEND_WRITE}] [<CommonParameters>]

Description

This command sets the value of a UEFI variable. If the variable does not exist, this command will create the variable.

Parameters

Name Argument Description
Name <String> Specifies the name of the UEFI variable to update or create
Value <Object> Specifies the new value for the UEFI variable. Note that a NULL value will delete the variable.

The value may be a byte array (type byte[], recommended), or a string which will be converted to UTF8 and stored as a byte array.
Namespace <String> Specifies a custom namespace. The namespace must be in the format of a UUID, surrounded by curly brackets.
Attributes <UEFIVariableAttributes> Specifies the attributes for the UEFI variable. For more information, see the UEFI specification linked below.

Attributes may be:

- VARIABLE_ATTRIBUTE_NON_VOLATILE: The firmware environment variable is stored in non-volatile memory (e.g. NVRAM).
- VARIABLE_ATTRIBUTE_BOOTSERVICE_ACCESS: The firmware environment variable can be accessed during boot service.
- VARIABLE_ATTRIBUTE_RUNTIME_ACCESS: The firmware environment variable can be accessed at runtime. Note Variables with this attribute set, must also have VARIABLE_ATTRIBUTE_BOOTSERVICE_ACCESS set.
- VARIABLE_ATTRIBUTE_HARDWARE_ERROR_RECORD: Indicates hardware related errors encountered at runtime.
- VARIABLE_ATTRIBUTE_AUTHENTICATED_WRITE_ACCESS: Indicates an authentication requirement that must be met before writing to this firmware environment variable.
- VARIABLE_ATTRIBUTE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS: Indicates authentication and time stamp requirements that must be met before writing to this firmware environment variable. When this attribute is set, the buffer, represented by pValue, will begin with an instance of a complete (and serialized) EFI_VARIABLE_AUTHENTICATION_2 descriptor.
- VARIABLE_ATTRIBUTE_APPEND_WRITE: Append an existing environment variable with the value of pValue. If the firmware does not support the operation, then SetFirmwareEnvironmentVariableEx will return ERROR_INVALID_FUNCTION.

Notes

  • It is not recommended that the attributes of an existing variable are updated. If new attributes are required, the value should be deleted and re-created.
  • The process calling these commands must be able to acquire 'SeSystemEnvironmentPrivilege' privileges for the operation to succeed. For more information, refer to "Modify firmware environment values" in the linked documentation below.
  • This command is not supported on legacy BIOS mode, only on UEFI mode.
  • This command requires elevated privileges.

Examples


PS C:\> PS>Set-HPUEFIVariable -Namespace "{21969aa8-681f-46be-90f0-6019ce9b0ee7}" -Name MyVariable -Value 1,2,3

PS C:\> PS>Set-HPUEFIVariable -Namespace "{21969aa8-681f-46be-90f0-6019ce9b0ee7}" -Name MyVariable -Value "ABC"

See also