About 253,000 results
Open links in new tab
  1. Read file line by line in PowerShell - Stack Overflow

    Nov 4, 2015 · I want to read a file line by line in PowerShell. Specifically, I want to loop through the file, store each line in a variable in the loop, and do some processing on the line. I know …

  2. Powershell retrieving a variable from a text file - Stack Overflow

    Is there a way to read a text file C:\\test.txt and retrieve a particular value? ie file looks like this: serverName=serv8496 midasServer=serv8194 I want to set the value of a variable in my scrip...

  3. powershell - How to load or read an XML file using ConvertTo-Xml …

    Dec 12, 2020 · Not reading a file with the correct encoding will result in mangled data or errors except in very basic or very lucky cases. The often-seen method of using Get-Content and …

  4. How to process a file in PowerShell line-by-line as a stream

    To minimize buffering avoid assigning the result of Get-Content to a variable as that will load the entire file into memory. By default, in a pipleline, Get-Content processes the file one line at a …

  5. Read UTF-8 files correctly with PowerShell - Stack Overflow

    Apr 2, 2014 · The same PowerShell script reads the file, adds some more content and writes it all as UTF-8 back to the same file This can be iterated many times With Get-Content and Out-File …

  6. How to read a line from a file in PowerShell - Stack Overflow

    Dec 13, 2016 · I want to read each line and ping for the first host (Host1), then the second host (Host2) and then the third host (Host3). While pinging each host name, I need to check the …

  7. powershell - Store Entire Text File Contents in Variable - Stack …

    Jun 13, 2024 · I'd like to use PowerShell to store the entire contents of a text file (including the trailing blank line that may or may not exist) in a variable. I'd also like to know the total number …

  8. powershell - Get last n lines or bytes of a huge file in Windows …

    Apr 9, 2016 · If you have PowerShell 3 or higher, you can use the -Tail parameter for Get-Content to get the last n lines. Get-content -tail 5 PATH_TO_FILE; On a 34MB text file on my local …

  9. powershell - How to load a JSON file and convert it to an object of …

    Mar 8, 2016 · Now I want to use ConvertFrom-Json to load the JSON file to memory and covert the output of the command to a FooObject object, and then use the new object in a cmdlet Set …

  10. How can I replace every occurrence of a String in a file with ...

    Jun 17, 2013 · Using PowerShell, I want to replace all exact occurrences of [MYID] in a given file with MyValue. What is the easiest way to do so?

Refresh