Powershell脚本导致输出中出现奇怪字符

Powershell脚本导致输出中出现奇怪字符,powershell,Powershell,我有这个剧本: # 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 {

我有这个剧本:

# 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
它很好用。但生成的文本文件包含以下内容:

IDR_ANNOUNCE_TEXT¬Not Found
IDC_BUTTON_UNDO¬Found
IDS_STR_CBS2¬Not Found

为什么会有奇怪的字符?

这是由于编码,您应该使用
set\u content
CmdLet,必要时可以使用
-encoding
param

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