-2
$content=Get-ExcelImport "P:\Scripts\cord\cord.xlsx"
$content |

foreach 

{ if ($_ -ilike "*Rick*") {Write-Output $_}}

The output is coming out as the name is getting searched in the excel sheet and getting out as an output in powershell. I am not able to export the data in a text file. Can anyone please help me with this

alroc
  • 27,574
  • 6
  • 51
  • 97
  • What have you tried with regard to outputting to a text file? Have you done any research on how to write a text file from Powershell? This is a pretty common task and there are numerous blog posts & code examples. – alroc Mar 09 '18 at 15:43
  • I've tried to export the output in a text file but it's not happening, I am a beginner in powershell scripting. So stuck at this stage. – Rishab Saha Mar 09 '18 at 15:45
  • See `PowerShell` [Out-file](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file?view=powershell-6). – Vivek Kumar Singh Mar 09 '18 at 15:45
  • Alright let me try that – Rishab Saha Mar 09 '18 at 15:51
  • @RishabSaha show what you've attempted so that people can help you fix it. "it's not happening" does not provide enough information to help you (without writing it entirely for you). – alroc Mar 09 '18 at 18:06

1 Answers1

1

Here is a link from a previous stack overflow question ( So this is a duplicate ?)

Output ("echo") a variable to a text file

The simplest Hello World example...

$hello = "Hello World"
$hello | Out-File c:\debug.txt

Edit : Maybe you need more help on formating your data ?

aurelienjo
  • 55
  • 1
  • 9
  • To format the data in your variable before putting it in a text file, otherwise your question is a duplicate... as @vivek-kumar-singh and alroc mentionned you should try some research before posting here – aurelienjo Mar 09 '18 at 15:58