creating cfg file with odd results

Welcome Forums General PowerShell Q&A creating cfg file with odd results

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 8 months ago.

  • Author
  • #28469

    Points: 28
    Rank: Member

    I was trying to make a config file to alter a programs behavior

    when I created the file using this method. the file size was twice as large as the next method.

    "UpdateDisable=1" > file.cfg
    "UpdateEnable=0" >> file.cfg

    when I used this method, the file size was half as large as the first method

    Add-Content file.cfg "UpdateDisable=1"
    Add-Content file.cfg "UpdateEnable=0"

    the files seemed the same, but only the second file actually worked as it was supposed to(changed the update settings). Was this because of the difference in size or some other subtle difference in the file structure or how the file was created?

  • #28473

    Points: 0
    Rank: Member

    It's the difference between a Unicode file and an ASCII file. Many output cmdlets use the -Encoding parameter to allow you to explicitly declare the type of output.

    From Get-Help about_redirection ...

        When you are writing to
        files, the redirection operators use Unicode encoding. If the file has a
        different encoding, the output might not be formatted correctly. To
        redirect content to non-Unicode files, use the Out-File cmdlet with its
        Encoding parameter.
  • #28524

    Points: 28
    Rank: Member

    Thank you!

The topic ‘creating cfg file with odd results’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort