function Get-HostsFileContent { <# .SYNOPSIS Reads the Contents of the Hosts File #> [CmdletBinding()] [OutputType([System.String])] Param( [Parameter(Mandatory = $false)] [string]$hostsPath = "$env:windir\System32\Drivers\etc\hosts" ) $logLead = (Get-LogLeadName); if (!(Test-Path $hostsPath)) { Write-Warning ("$logLead : Could not read hosts file from {0}" -f $hostsPath) return } Write-Verbose ("$logLead : Reading Hosts file from {0}" -f $hostsPath) return [System.IO.File]::ReadAllLines($hostsPath) }