Private/Helper/Test-IsHostsFileModified.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Test-IsHostsFileModified { <# .SYNOPSIS Checks if the hosts file has been modified. .DESCRIPTION This function reads the hosts file and checks for any non-comment lines that contain an IP address, indicating the file has been modified. .PARAMETER None .EXAMPLE Test-IsHostsFileModified .NOTES The function uses Get-Content to read the hosts file and checks each line for modifications. #> $Hosts = Get-Content "C:\Windows\System32\drivers\etc\hosts" -Force FOREACH ($Line in $Hosts) { IF ($Line.Length -gt 1) { IF ($Line.Substring(0,1) -ne "#") { IF ($Line -like "*.*") { RETURN $True } } } } RETURN $False } |