Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

MSFT_HostsFile: Host entries that have multiple entries on a single line fail

未关闭
#421 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
powershell
领域
networking

调研方向

首先定位 MSFT_HostsFile 的实现并检查第 233-259 行,这些行处理每行包含多个条目的情况,然后检查第 368 行附近的比较。使用提供的 HostsFile 配置重现此问题,并验证重复运行 LCM 不会重新写入未更改的主机条目。

由索引模型根据 Issue 内容生成。

描述

discussion

Details of the scenario you tried and the problem that is occurring

When defining multiple entries on a single line it will write them to the host file every time the LCM kicks off.

Line 233 -259 takes in account for multiple entries per line but then a compare happens later against that array and a string that was passed into the Get-HostEntry.

Suggested solution to the issue

Change line 368
FROM: if ($result.Host -eq $HostName)
TO: if ([string]$result.Host -eq HostName)

The DSC configuration that is used to reproduce the issue (as detailed as possible)
HostsFile "Test1"
            {
                HostName  = 'test-ocsp-responder testVM.lab.local'
                IPAddress = '192.168.1.50'
                Ensure    = 'Present'
            }
The operating system the target node is running
OsName               : Microsoft Windows Server 2012 R2 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsBuildLabEx    : 9600.19358.amd64fre.winblue_ltsb_escrow.190505-1600
OsLanguage           : en-US
OsMuiLanguages       : {en-US}
Version and build of PowerShell the target node is running
Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Version of the DSC module that was used ('dev' if using current dev branch)

6.1.0.0 The code for this issue looks the same.

主要语言
PowerShell
星标
234
派生
92
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dsccommunity/NetworkingDsc 的其他 Issue

查看 dsccommunity/NetworkingDsc 的全部 Issue

相似的 Issue

更多 Networking Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。