Asked by:
Automation for deletion of many invoices

General discussion
-
HI team,
I am trying to do an automation where the scenario is like: I am having a text file ABC.txt which contains all numbers :
ABC.txt:
12234
12345
123455
Through the powershell scripting, I want to have the output in a text file like :
Sunny day
Rainy Day
Windy day
This is 12234
This is 12345
This is 123455
So I have perform the below scripting:
$File1 = @((Get-Content "E:\ABC.txt"))
For($a = 0;$a -lt $File1.count;$a++){
-join ("This is ", $File1[$a]) | Out-File -FilePath "E:\XYZ.txt" -Append
}The above script is showing output in XYZ.txt file:-
This is 12234
This is 12345
This is 123455
Can you please let me how to add the following on top of the above output:
Sunny day
Rainy Day
Windy day
- Changed type Bill_Stewart Thursday, September 5, 2019 9:52 PM
- Moved by Bill_Stewart Thursday, September 5, 2019 9:53 PM This is not "do homework for me" forum
All replies
-
Hi All,
I am new to Microsoft Powershell. I am stuck in middle of somewhere. Appreciate if I get a help in this matter. Below is the text.file which contains numbers:
ABC.text
234567899
234567890
233445678
I want the output to be (in the same file by powershell scripting):
This is 234567899
This is 234567890
This is 233445678
Can you please help me in creating this.
Regards,
ROY
- Merged by Bill_Stewart Friday, August 9, 2019 5:13 PM Duplicate
-
Oliv# Many Way to do this # You must add `n for adding a carriage return and -append parameter (-join("this is ", "$var", "`n")) | Out-File -FilePath $MyOutputFile -Append # or a better way : no needs of CR, it's by design, and the native cmdlet function is to add :-) Add-Content -Value (-join("this is ", "$MyVar")) -Path $MyOutputFile
# i.e. :
$MyOutputFile ="c:\temp\Outputfile.txt"
foreach ($var in $VarCollection) { Add-Content -Value (-join("this is ", "$MyVar")) -Path $MyOutputFile }
- Edited by Oliv - TheFrog Thursday, August 8, 2019 2:03 PM
-
Oliv# Many Way to do this # You must add `n for adding a carriage return and -append parameter (-join("this is ", "$var", "`n")) | Out-File -FilePath $MyOutputFile -Append # or a better way : no needs of CR, it's by design, and the native cmdlet function is to add :-) Add-Content -Value (-join("this is ", "$MyVar")) -Path $MyOutputFile
# i.e. :
$MyOutputFile ="c:\temp\Outputfile.txt"
foreach ($var in $VarCollection) { Add-Content -Value (-join("this is ", "$MyVar")) -Path $MyOutputFile }
\_(ツ)_/
-
Hi Oliv,
I have ran the above code but it is not showing the expected output in ABC.txt file.
Can you please provide some other solution for this? I want to display the following output in ABC.txt file only
This is 234567899
This is 234567890
This is 233445678
Regards,
ROY
- Edited by Eshan Roy Thursday, August 8, 2019 3:14 PM edit
-
-
Can you please share as this is high priority I have to finish this by EOD.
I'm afraid you're going to have to adjust your expectations for this forum. Please read this first:
This forum is for scripting questions rather than script requests
-- Bill Stewart [Bill_Stewart]
- Edited by Bill_Stewart Thursday, August 8, 2019 3:26 PM
-
-
-