Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8785971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:29:22+00:00 2026-06-13T21:29:22+00:00

I want to read a specific string from a text file and output the

  • 0

I want to read a specific string from a text file and output the string into another text file.

My text file (Sample.txt) looks like below:

@{AssemblyName=Microsoft.Office.Excel, Version=1.0.0.0, Culture=neutral,     PublicKeyToken=1y08bdf1111e0105c; Path=C:\Tes\app1\cc\application; ProjectPath=C:\test\application\Application.vbproj; Name=Microsoft.Office.Excel}

@{AssemblyName=System; Path=C:\Tes\app2\ser\application; ProjectPath=C:\test\application2\Application.vbproj; Name=System}

I do not want to include anything except the assemblyname.. i.e, the script should not consider version, culture etc.

The text file has lot of such assembly information.
I would like to read only the AssemblyName and write that to another text file in powersehll.
For Ex: The output.txt should contain only Microsoft.Office.Excel.

Also, I want to exclude few assembly names that start with a specific string like for eg: System. How can I do that?

I tried below, but it’s not writing anything to the output.txt.

$workdir = "C:\Test"
$Txt = "$workdir\Sample.txt"

Function GetAsmName($rTxt)
{

Get-Content $Txt

$regex = '@{AssemblyName="(\w*?)"[,|;]'
$matches = (select-string  -Path $Txt -Pattern $regex)
$matches | Select -Expandproperty Matches | Select @{n="Name";e={$_.Groups[1].Value}}
Set-Content -path $workdir\Output.txt -value $matches
}

Any help would be greatly appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:29:24+00:00Added an answer on June 13, 2026 at 9:29 pm

    Try:

    $workdir = "C:\Test"
    $Txt = "$workdir\Sample.txt"    
    Function GetAsmName($rTxt)
    {    
    $captures = gc $rTxt | 
                select-string -Pattern '(?<=AssemblyName=)([^;|,]*)' -allmatches |
                select -expa matches | select -expa value    
    Set-Content -path $workdir\Output.txt -value $captures
    }
    
    GetAsmName $Txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read a text file which has text as follows(sample) abc ip-32-56-198-18.com
I'm using the following StreamReader to read from text file string temp = fs.ReadToEnd
I want to read a specific line from an html source code. Im storing
I have a text file. I want read that file. But In that if
I want to read a INI file from python, and I came up with
I am reading in a String from a text file which contains a date
I have a C program that reads from a txt file. The text file
I want to read from a file each line and edit only the lines
How do I write to a txt file, so I would like a string
I'm trying to read a text from a text file, read lines, delete lines

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.