How can I change this Powershell script so as to list all the identifiers?

Script:

Output desired:

Company:              CompanyCode        
Type:                       810
Identifier:               000000001
Identifier:               000000002
Identifier:               000000003
Control Number:  123456789


I need the scrip to list any identifiers it finds with each data set starting with ISA and ending in IEA which are found within the file.
100questionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Neil RussellTechnical Development LeadCommented:
Please supply a sample text file for input and document its output.
0
100questionsAuthor Commented:
Sample Input data:
ISA*00*          *00*          *12*1234567891     *ZZ*COMPANYCOL     *213456*1234*A*00123*123000010*1*P*>~
GS*IN*2134567891*1234567891*20141024*1234*00*X*001234~
ST*810*123456789~
BIG*20141020*123456.*20140917*1234567.~
N1*RI*COMPANY*0*000000000~
N1*BT*COMPANY 2*0*12345678910000~
ITD*00*2*****00~
DTM*000*20141020~
FOB*CC~
IT1*1*200*CA*5.4**UN*123456789123*VN*01234A~
IT1*2*50*CA*1.4**UN*213456789122*VN*02345A~
IT1*3*60*CA*12.4**UN*789456123123*VN*06789A~
TDS*1234567~
ISS*1234*CA*12345*LB~
SE*12*123456789~
ST*810*98763254~
BIG*20141020*123456.*20140917*1234567.~
N1*RI*COMPANY*0*000000000~
N1*BT*COMPANY 2*0*12345678910000~
ITD*00*2*****00~
DTM*000*20141020~
FOB*CC~
IT1*1*10*CA*1.4**UN*783456789123*VN*01235A~
IT1*2*2*CA*2.4**UN*789456789122*VN*02346A~
IT1*3*30*CA*1.5**UN*239456123123*VN*06788A~
TDS*1234567~
ISS*1234*CA*12345*LB~
SE*12*98763254~
GE*1*10~
IEA*1*123000010~

Open in new window

0
x-menIT super heroCommented:
$(gc c:\temp\my.imput.txt).split("*")
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Barry MolenwijkTechnical Support Specialist IICommented:
Which parts of the input would you like included in the output? Could you highlight those or create the exact output you want based on this input so we can reverse-engineer it?
0
Chris DentPowerShell DeveloperCommented:
You rather missed out the:

> document its output

This question cannot be answered without some kind of documentation to allow us to figure out which bits of the snippet represent the fields you've requested.

Chris
0
100questionsAuthor Commented:
I've requested that this question be deleted for the following reason:

Not enough information was provided for the experts, deleting this.
0
Joe KlimisCommented:
Hi would you like me to  answer this question , i will create you a script
0
100questionsAuthor Commented:
Sure Joe, if you have enough info to go by, then yes if possible.
0
Neil RussellTechnical Development LeadCommented:
We would all like to answer the question but first you have to do as we asked and provide DETAILS of input AND outputs, rules of how to get from input to output.
What you have given us so far allows only guessing.
0
Neil RussellTechnical Development LeadCommented:
Is deleting a question because you didnt provide enough information and wont provide it, a good cause for deletion and points refund?
0
100questionsAuthor Commented:
Post to everyone who wrote in..   I've posted an Output example, and I've posted the Data Input example.   If this is not enough information for anyone, and since none of the experts have provided a solution, and I've requested for this to be closed - if no one can work with what I have, then we can safely delete the question...
0
Joe KlimisCommented:
Hi

Please Try the following and let me know how you get on

 
$dataFile		= "data3.txt"
$resultsFile	= "Output.txt"
out-file $resultsFile  -encoding ascii
$data 		 	= get-content $dataFile
$result			= ""
write-output "Processing $($data.count) lines of data"
$count  = 0

$count=0
$lines=@()
$allident = @()
foreach ($line in $data)
{
$lines+=$line
	$SplitLine =$line.split("*")
	switch ( $splitLine[0] )
	{
	"N1" 	{
			$company = $splitline[1]
			$type=""
			$Ident=""
			$controlnumber=""
			
			}

	"ST" 	{ 	$count++
				$doctype  =  $splitline[1]}
	"SE" 	{ 	
				$controlNumber  =  $splitline[2].split("~")[0]}
	
	"IT1" 	{   
				$ident = $SplitLine[9].split("~")[0]
				$allident += $ident
				}
	"IEA"	{
				"Company:  $company"|out-file $resultsFile -append -encoding ASCII
				"Type:     $doctype"| out-file $resultsFile -append -encoding ASCII
				foreach ($idents in $allident ) {"Identifier: $idents"| out-file $resultsFile -append -encoding ASCII}
				"Control Number: $controlnumber"| out-file $resultsFile -append -encoding ASCII
				"" | out-file $resultsFile -append -encoding ASCII
				$allident = @()
			}
	}
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Neil RussellTechnical Development LeadCommented:
@100questions
It is customary when asking for help, in any walk of life, to be courteous and responsive. When you are asked for an explanation or further details, a response of  "I've posted an Output example, and I've posted the Data Input example.   If this is not enough information for anyone, and since none of the experts have provided a solution, and I've requested for this to be closed - if no one can work with what I have, then we can safely delete the question"  is hardly professional or conducive to eliciting a good response.

You question gave two bits of data with no explanation and nod no details of how it was structured.  As I stated earlier, we could have Guessed and wasted everyone's time, instead I asked for a quick explanation.

Alas you either don't know what you want or how to articulate it and would rather alienate the experts with your responses.
0
100questionsAuthor Commented:
@Neilsr - Good day.  Thanks for your response.  I do not wish to come across as unprofessional.  In the future, I will try to provide more information.  Regards.   100questions.
0
Neil RussellTechnical Development LeadCommented:
Just another note. Your question is titled...

How can I change this Powershell script so as to list all the identifiers?

You did not however provide ANY powershell script or snippets for us to change!
0
100questionsAuthor Commented:
Hi Neil.  Yes, you are correct, this was my omission, I should either have included the script or changed the title.  My apologies.
0
Neil RussellTechnical Development LeadCommented:
So you have a script already??  Had you uploaded that too, you would probably had an answer in the first hour....
0
100questionsAuthor Commented:
Hi Neil.  I don't have a script handy at this time.  I will try Joe's script to see how it works.
0
100questionsAuthor Commented:
Thanks Joe for working on this, much appreciated.

This was the output from your script:

Company:  BT
Type:     810
Identifier: 01234A
Identifier: 02345A
Identifier: 06789A
Identifier: 01235A
Identifier: 02346A
Identifier: 06788A
Control Number: 98763254
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.