It might depend on what file.exe is and the output it produces.
This example seems to work for me.
If you question is really "how do I output the contents of a variable into a file as utf8", just look at how I create the utfString.txt file.
Function Execute-Command ($commandTitle, $commandPath, $commandArguments)
{
Try {
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $commandPath
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.WindowStyle = 'Hidden'
$pinfo.CreateNoWindow = $True
$pinfo.Arguments = $commandArguments
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
$p.WaitForExit()
$p | Add-Member "commandTitle" $commandTitle
$p | Add-Member "stdout" $stdout
$p | Add-Member "stderr" $stderr
}
Catch {
}
$p
}
$utfString = '蓝屏日志 请问怎么处理呢'
$utfString | out-file -FilePath c:\temp\utfString.txt -Encoding utf8 # create a file with utf8 contents
$DisableACMonitorTimeOut = Execute-Command -commandTitle "test" -commandPath "C:\windows\system32\cmd.exe" -commandArguments "/c type c:\temp\utfString.txt"
"Here is stdout: {0}" -f $DisableACMonitorTimeOut.stdout