Appending entry into the HOSTS file

(imported comment written by SystemAdmin)

Here’s a little relevance for PCs that don’t have “X.X.X.X Our-Server-01.any.domain.dcd”

exists file "hosts"
whose
(
not exists lines
whose
(
it != ""
and
it as left trimmed string starts with "X.X.X.X"
and
it as right trimmed string as lowercase ends with “our-server-01.any.domain.dcd”
)
of it
)
of folder “drivers\etc” of system folder

Obviously X.X.X.X is an IP address, which is why I don’t lowercase it. :slight_smile:

I’m also checking via “starts with” rather than “contains” because it could have the IP address commented out with a “#”.

Checking it != “” because there’s a caution using the trimmed string operator. See: http://forum.bigfix.com/viewtopic.php?id=4317

Hmm… Did the trimmed string operator get fixed in BES 8.0?

-Paul