locked
get-content broken after patch tuesday ? RRS feed

  • Question

  • Hello,

    (I'm Using Powershell 2.0)

    After installing the patches from Windows update some scripts using get-content are broken and if I try

    $file = "c:\temp\sometextfile.txt"

    $a = get-content $file

    foreach ($line in $a){write-host $line}

    each invocation of write-host displays the entire contents of the textfile as a single line instead of just one line of the text file.

    so the result is that (the number of lines in the file) x (the entire textfile) is displayed

    Looks like CRLF is no longer seen as EOL by get-content, OTOH $a.length is still correct (number of lines in the textfile +1)

    I didn't see a update for powershell in the patch list , so maybe a dotNet update to the object/method used by get-content is causing this ?

    Can anyone confirm this is broken for them too  ?

    Regards,

    Rob Hagman.


    • Edited by rhagman Thursday, July 12, 2012 7:51 AM
    Thursday, July 12, 2012 7:44 AM

Answers

  • Thanks for all your comments,

    I gave the PC a extra reboot and that fixed it, still not sure what caused it, maybe something

    didn't fully finished installing at the first reboot after installing the patches.

    Rob Hagman.

    Thursday, July 12, 2012 5:53 PM

All replies

  • Hello Rob

    i do not see the same problem. (running win8)

    you do not describe which OS you are running?


    Best Regards
    Jakob Gottlieb Svendsen
    Trainer/Consultant - Coretech A/S - Blog
    MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript Mastering System Center Orchestrator 2012 - 3 day workshop - worldwide training click here

    Thursday, July 12, 2012 7:50 AM
  • Hello Jacob

    I'm running Windows 7 Ultimate

    Rob Hagman.

    Thursday, July 12, 2012 7:52 AM
  • I'm running Windows 7 64-bit Ultimate, and have the latest patches installed.  I am running Powershell V3, and I tested the code sample.  No problem, code executed correctly.

    Grant Ward, a.k.a. Bigteddy


    • Edited by Bigteddy Thursday, July 12, 2012 10:06 AM
    Thursday, July 12, 2012 10:06 AM
  • Maybe someting has changed the culture or other fundamental settings.

    If the files are unicode and the culture is wrong the end of lines may not be recognized.


    ¯\_(ツ)_/¯

    Thursday, July 12, 2012 5:21 PM
  • Thanks for all your comments,

    I gave the PC a extra reboot and that fixed it, still not sure what caused it, maybe something

    didn't fully finished installing at the first reboot after installing the patches.

    Rob Hagman.

    Thursday, July 12, 2012 5:53 PM