Ask Your Question
2

How can I convert a Powershell list into a string format?

asked 2022-10-17 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-03-10 09:00:00 +0000

qstack gravatar image

You can use the -join operator to convert a PowerShell list into a string format. Here's an example:

$list = "item1", "item2", "item3"
$string = $list -join ","
Write-Output $string

This will output: item1,item2,item3

In this example, we use the -join operator to concatenate each item in the $list variable with a comma , as a separator. The resulting string is then stored in the $string variable.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-10-17 11:00:00 +0000

Seen: 7 times

Last updated: Mar 10 '22