Set a UEFI variable value.




This function sets the value of a UEFI variable. If the variable does not exist, it is created.


Name Argument Description
Name <String> The name of the UEFI variable to update or create.
Value <Object> The new value for the 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> Look for the variable in the specified custom namespace. The namespace must be in the format of a UUID, surrounded by curly brackets.
Attributes <UEFIVariableAttributes> The attributes for the 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.


  • 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 functions 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 function is not supported on legacy BIOS mode, only on UEFI mode.
  • This function requires elevated privileges.


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