2017-02-16 218 views
1

造成性格怪異我有這樣的腳本: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 { 
    $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 

爲什麼它有奇怪的字符?

回答

2

這是由於編碼,您應該使用set_content CmdLet,如果需要,您可以在-encoding參數上播放。

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