Andrew Truckle
Andrew Truckle

Reputation: 19197

Powershell script causing a strange character in the output

I have this script:

# Read in the RESOURCE ID values I want to locate
$TextToFind = Get-Content -Path .\ResourceIDs.txt

$Text = ""
$PathArray = @()
$Results = ".\ResultsResourceIDs.txt"

# Now iterate each of these text values
$TextToFind | ForEach-Object {
    $Text = $_
    Write-Host "Checking for: " $Text

    If ((Get-Content .\Resources.rc) | Select-String -Pattern $Text) {
        $PathArray += $Text + "¬Found"
    }
    Else {
        $PathArray += $Text + "¬Not Found"
    }
}



Write-Host "Contents of ArrayPath:"
$PathArray | ForEach-Object {$_}

$PathArray | % {$_} | Out-File $Results

It works fine. But the resulting text file has content like:

IDR_ANNOUNCE_TEXT¬Not Found
IDC_BUTTON_UNDO¬Found
IDS_STR_CBS2¬Not Found

Why does it have the strange character?

Upvotes: 1

Views: 1515

Answers (1)

JPBlanc
JPBlanc

Reputation: 72680

This is due to encoding, you should use set_content CmdLet and you can play on -encoding param if necessary.

$PathArray | % {$_} | Set-Content $Results -Encoding UTF8

Upvotes: 2

Related Questions