Reputation: 2255
I'll explain what i want by example, not sure how to explain it another way.
Heres the code im using :
Get-WmiObject win32_share | select name, path
an example entry is from the above is:
name path
ADMIN$ C:\windows
C$ C:\
I want to put all names and paths into one variable. I want the string to look something like:
"Name: admin, path: C:\windows ; Name: c$, path: C:\ ; ect ect.."
Any ideas?
Upvotes: 0
Views: 546
Reputation: 301157
Slight modification in approach from @SINTER's answer and using more POSH syntax:
$out="";Get-WmiObject win32_share | %{ $out+="Name: {0}, Path: {1}; " -f $_.Name, $_.Path}
Upvotes: 3
Reputation: 8280
Something like this:
[string]::Join("; ", (Get-WmiObject win32_share | % { [string]::Format("Name: {0}, Path: {1}", $_.Name, $_.Path)}))
Upvotes: 0