Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HostsFile Get-TargetResource returns an array for HostName if there is one or more spaces at the beginning of the line #526

Open
cdhunt opened this issue May 31, 2024 · 0 comments · May be fixed by #527

Comments

@cdhunt
Copy link

cdhunt commented May 31, 2024

Problem description

HostsFile Get-TargetResource returns an array for HostName if there is one or more spaces at the beginning of the line. This formatting appears to come from the PowerToys Hosts File Editor.

  127.0.0.1     argo.docker.internal
# Added by Docker Desktop
  192.168.1.160 host.docker.internal
  192.168.1.160 gateway.docker.internal
Invoke-DscResource -Name HostsFile -ModuleName NetworkingDsc -Method get -Property @{HostName='argo.docker.internal'}

Name                           Value
----                           -----
Ensure                         Present
IPAddress
HostName                       {127.0.0.1, argo.docker.internal}

Verbose logs

n/a

DSC configuration

n/a

Suggested solution

Run Trim before Split.

Operating system the target node is running

Windows 11

PowerShell version and build the target node is running

Name                           Value
    ----                           -----
    PSVersion                      7.4.2
    PSEdition                      Core
    GitCommitId                    7.4.2
    OS                             Microsoft Windows 10.0.22621
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0

NetworkingDsc version

Name          Version Path
    ----          ------- ----
    NetworkingDsc 9.0.0   C:\Users\[username]\Documents\PowerShell\Modules\NetworkingDsc\9.0.0\NetworkingDsc.psd1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant