Skip to main content

All Questions

1 vote
1 answer
50 views

How to ignore commas in cell value when using StreamWriter to write to csv output

I am processing a .txt file, which needs to be repeated every 10 lines. I then want to turn this into a .csv file. However, some of the .txt file contains commas which I want to keep in a single cell ...
Tommy K's user avatar
  • 1,799
1 vote
1 answer
60 views

Text file is locked for openning when running the script but I can open it manually

I have the following PowerShell script: do{ $Error[0]= $null $StreamWrite = [System.IO.StreamWriter]::new($PathToTextFile,$true,[system.Text.Encoding]::Unicode) }while ($Error[0] -ne $...
POL's user avatar
  • 21
1 vote
1 answer
124 views

"WriteLine" stop writing a file. (Windows PowerShell)

I am trying to create a script for the university, that sorts the number of processes in the system by their handles number and saves them in a file. So far so good, sounds easy. But when I thought I ...
Altiubb's user avatar
  • 13
1 vote
1 answer
251 views

How to Ignore lines with StreamWriter WriteLine

trying to figure out how to ignore or stop specific lines from being written to file with StreamWriter. Here is the code I'm working with from How to pass arguments to program when using variable as ...
user avatar
0 votes
2 answers
686 views

Powershell write array using StreamWriter

I'm new to PowerShell and am trying to write a script that will allow me to read through a very large text file and extract certain lines if they begin with "2020". When a match is found, it ...
Chester205's user avatar
0 votes
1 answer
598 views

How can StreamWriter WriteLine append instead of overwrite in Powershell

I am trying to get this StreamWriter WriteLine to append the text to the already existing file but it's overwriting it. $inputFile = ".\input.txt" $outputFile = ".\output.txt" $...
O. Pine's user avatar
  • 27
0 votes
1 answer
1k views

Tell Powershell to wait for foreach to finish writing to txt file

I have a .ps1 script that takes some of our internal SQL data and syncs it to a Google API. It does this by running a foreach against our data, using logic to generate the API commands, and writing ...
Jensen010's user avatar
  • 445
1 vote
2 answers
318 views

Encoding problem when creating a txt-file for outlook signatures that contains special characters, using Powershell

I'm having some issues with a powershell script that creates signatures for Microsoft Outlook. I'm not very familiar with powershell and are attempting to modify an existing script. The problem I have ...
Penguin616's user avatar
2 votes
1 answer
132 views

Is there a PowerShell logging module that uses StreamWriter to write to a text file?

I checked a dozen logging modules published at PowerShellGallery.com but every one of them uses a variation of the Write-Output or piping to Out-File approach which is really inefficient for bigger ...
Alek Davis's user avatar
  • 10.7k
1 vote
1 answer
195 views

How to write information to .csv file via streamwriter

I am trying to write a lot of information to a .csv file using a powershell script. I'm running this script on 1500 computers from the "Run Script" function within SCCM Configuration Manager. The ...
Manning's user avatar
  • 99
0 votes
1 answer
184 views

Update LastWriteTime without closing the FileStream

I am successfully using StreamWriter to incrementally write a log file, and to ensure real time logging I have tried both AutoFlush as well as the Flush() method. Both work, the log file updates in ...
Gordon's user avatar
  • 6,693
0 votes
1 answer
201 views

PowerShell StreamWriter path property

Is it possible to take an existing StreamWriter variable and see the path that it is using? So far as I can tell (using Get-Member on the variable) the answer is no. Just wanting to verify I am not ...
Gordon's user avatar
  • 6,693
1 vote
3 answers
350 views

powershell write to file

I've written a GUI for making changes in AD and I need every action logged. This GUI is used by multiple users at once and writes to one file but only first person that writes to the log file can ...
Kamil Maciejewski's user avatar
0 votes
1 answer
2k views

StreamWriter(Stream, Encoding) not working in PowerShell

I wanted to convert a file from UTF-16 to ANSI with Powershell and I encountered some behavior that I don't understand. My (simplified) script is $encoding = [System.Text.Encoding]::GetEncoding(1250)...
Tom V's user avatar
  • 350
0 votes
1 answer
3k views

StreamWriter encoding

I am processing some very large files to find and replace strings, so I need to use StreamReader and StreamWriter. And I also need to support multiple encoding. I have $reader = [IO.StreamReader]::...
Gordon's user avatar
  • 6,693

15 30 50 per page