How to grab the local part of an email address RRS feed

  • Question

  • Hi,

    I am trying to write a script to grab the input from a text file with a 10-20 email addresses.

    I want it to output to another text file everything before the @ symbol. For example: example@windows.com. I want only the example.

    so far I have this 

    $input_path = 'C:\Users\clau\Downloads\Script\Powershell Test.txt'
    $output_file = 'C:\Users\clau\Downloads\Script\Powershell 2.txt'
    $regex.split(' @')[1]

    But I am getting stuck. Does anyone have any advice for me?

    Thanks you

    • Edited by Laaauuuuuu Thursday, July 6, 2017 9:01 PM
    Thursday, July 6, 2017 8:55 PM

All replies

  • Please format your code as code. There is an according option on the editbar when you create a post. Thanks

    You can get the content of your text file with Get-Content, then you can pipe this content to a Foreach-Object and -split what's in our pipeline variable at the '@', take the [0] part of it and pipe it to Out-File.  

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Proposed as answer by Wizend Saturday, July 8, 2017 11:52 AM
    Thursday, July 6, 2017 9:22 PM