Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 13
    at least this one could be used in foreach Commented Jun 9, 2020 at 7:51
  • 4
    Please add that if you are using commands as inputs, wrap the command inside $().....eg... -join($(cmd1), ",", $(cmd2)) ...took me too long to figure out as I am new to powershell Commented Sep 11, 2020 at 15:49
  • 1
    @S.Melted why wrap inside $()? Commented Nov 17, 2020 at 23:19
  • Upon further review, only () is necessary for my need. For example: -join("Timestamp: ", Get-Date) gives an error, while -join("Timestamp: ", (Get-Date)) runs fine. However, this explains when $() would be necessary. Commented Dec 23, 2020 at 19:20
  • Write-Host -join("Hello", " ", "world") will not join as the whole join argument needs brackets including the name of the arg = join. Commented Oct 28, 2021 at 8:39