Reputation: 2769
I have a PowerShell-V2 script I am trying to run. Very simply, I pass it an application, and it outputs the result of the win32_process. e.g.
$filter = "name like '%"+$_Application+"%'"
$result = Get-WmiObject win32_process -Filter "$filter"
However I need to get this into a file. But when I run:
write-host $result
I just seem to get the "__RELPATH" result, and not the whole thing.
Trying to get it into a file results in the same thing. Is there a way of doing this, without me having to loop through one by one, listing each one in turn?
Upvotes: 1
Views: 4157
Reputation: 58931
You can use the Out-File
cmdlet:
$result | Out-File 'your_file_path.txt'
Note: You may want to set the encoding within the Out-File
cmdlet. E. g. -Encoding utf8
Upvotes: 2