Set Hosts File Entry
Adds or removes a single entry in the Windows hosts file, so a hostname can be pointed at a specific IP address on the endpoint.\n\nAdding an entry that is already present changes nothing, and removing an entry leaves every other line in the file untouched.\n\nIf the hostname already points at another IP address, that entry is replaced so the hostname resolves to the IP address specified here.
Parameters
Section titled “Parameters”Action
Section titled “Action”Required — Default: Add
Select whether the entry should be added to the hosts file or removed from it. Allowed values: Add, Remove.
IP Address
Section titled “IP Address”Required
The IP address the hostname should resolve to. Both IPv4 and IPv6 addresses are accepted.\n\nExample:\n192.168.1.50\n::1
Hostname
Section titled “Hostname”Required
The name that should resolve to the IP address. Use the name exactly as it is typed in a browser or a command line, without a protocol and without a path.\n\nExample:\nintranet.contoso.com
Comment
Section titled “Comment”Optional
An optional note that is written at the end of the entry, so it is visible in the hosts file who added the line and why. Leave it empty to write the entry without a note.\n\nExample:\nAdded by IT for the intranet migration
Back Up The Hosts File
Section titled “Back Up The Hosts File”Required — Default: True
Enable to save a timestamped copy of the hosts file before it is changed, so the previous content can be restored if needed. The copy is placed in the PowerBricks log folder. Disable to change the hosts file without saving a copy. No copy is saved when nothing has to be changed.
Details
Section titled “Details”- Category: System
- Brick ID:
Hosts-Entry-Set
{ "category": "system", "description": "Adds or removes a single entry in the Windows hosts file, so a hostname can be pointed at a specific IP address on the endpoint.\\n\\nAdding an entry that is already present changes nothing, and removing an entry leaves every other line in the file untouched.\\n\\nIf the hostname already points at another IP address, that entry is replaced so the hostname resolves to the IP address specified here.", "developerVendor": "CapaSystems A/S", "displayName": null, "id": "Hosts-Entry-Set", "name": "Set Hosts File Entry", "parameters": [ { "allowManualInput": false, "defaultValue": null, "defaultValueObject": { "id": "Add", "name": "Add" }, "description": "Select whether the entry should be added to the hosts file or removed from it.", "id": "Action", "name": "Action", "regExValidation": "", "required": true, "type": "ComboBox", "value": null, "values": [], "valuesObject": [ { "id": "Add", "name": "Add" }, { "id": "Remove", "name": "Remove" } ] }, { "allowManualInput": false, "defaultValue": "", "defaultValueObject": null, "description": "The IP address the hostname should resolve to. Both IPv4 and IPv6 addresses are accepted.\\n\\nExample:\\n192.168.1.50\\n::1", "id": "IpAddress", "name": "IP Address", "regExValidation": "^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$|^([A-Fa-f0-9]{0,4}:){2,7}[A-Fa-f0-9]{0,4}$", "required": true, "type": "TextBox", "value": null, "values": [], "valuesObject": null }, { "allowManualInput": false, "defaultValue": "", "defaultValueObject": null, "description": "The name that should resolve to the IP address. Use the name exactly as it is typed in a browser or a command line, without a protocol and without a path.\\n\\nExample:\\nintranet.contoso.com", "id": "Hostname", "name": "Hostname", "regExValidation": "^[A-Za-z0-9_]([A-Za-z0-9_\\-\\.]*[A-Za-z0-9_])?$", "required": true, "type": "TextBox", "value": null, "values": [], "valuesObject": null }, { "allowManualInput": false, "defaultValue": "", "defaultValueObject": null, "description": "An optional note that is written at the end of the entry, so it is visible in the hosts file who added the line and why. Leave it empty to write the entry without a note.\\n\\nExample:\\nAdded by IT for the intranet migration", "id": "Comment", "name": "Comment", "regExValidation": "", "required": false, "type": "TextBox", "value": null, "values": [], "valuesObject": null }, { "allowManualInput": false, "defaultValue": "True", "defaultValueObject": null, "description": "Enable to save a timestamped copy of the hosts file before it is changed, so the previous content can be restored if needed. The copy is placed in the PowerBricks log folder. Disable to change the hosts file without saving a copy. No copy is saved when nothing has to be changed.", "id": "BackupBeforeChange", "name": "Back Up The Hosts File", "regExValidation": "", "required": true, "type": "Boolean", "value": null, "values": [], "valuesObject": null } ], "powershell": { "base64Encoded": true, "function": "ZnVuY3Rpb2..." }, "type": "powerbrick", "version": "2026.10.8.1"}