ps/Modules/Alkami.PowerShell.Common/Public/Get-HostsFileContent.ps1
2023-05-30 22:51:22 -07:00

23 lines
583 B
PowerShell

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)
}