PowerShell:有关%(百分比)的问题及其在以下脚本片段中如何工作



我正在努力改善我的powershell,我一直在努力过度缩小脚本,但我仍然很绿色,所以我希望有人可以将我指向正确的方向。

我了解%是foreach-object,但这有点不同。如果您可以帮助我在此片段中理解它们,这将不胜感激。

function Replace-StringVariables ($string, $location) {
    $string = $string.Replace("%locationID%",$location.locationID)
    $string = $string.Replace("%locationName%",$location.locationName)
    $string = $string.Replace("%locationCode%",$location.locationCode)
    $string = $string.Replace("%regionName%",$location.regionName)
    $string = $string.Replace("%regionCode%",$location.regionCode)
}

所以,我在此弄清楚了$strong的混乱,我在其中一些情况下和之后不了解%'s。如果有帮助,这是一个广告项目。

没关系,我已经弄清楚了。它正在从以前的JSON中提取信息,该信息已转换为原始数据。至少,这就是我的理解。

最新更新