Forum Discussion
Why do I get name printed 3 times instead of 2?
- Aug 05, 2024
senglorychange line 34 to:
trySetWptColor $wpt $wptExisting
Passing multiple arguments to a function in PowerShell should not use commas to separate them, and function calls should not use parentheses. By using a comma, you are actually passing two variables merged into a single array ($wpti) whose first element is of type System.Xml.XmlElement and whose second element is a hashtable. The second variable ($wptExisting) is null. On line 12, Write-Host was writing all elements of the array that had a property called Name.
senglorychange line 34 to:
trySetWptColor $wpt $wptExisting
Passing multiple arguments to a function in PowerShell should not use commas to separate them, and function calls should not use parentheses. By using a comma, you are actually passing two variables merged into a single array ($wpti) whose first element is of type System.Xml.XmlElement and whose second element is a hashtable. The second variable ($wptExisting) is null. On line 12, Write-Host was writing all elements of the array that had a property called Name.