Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

File font garbled;

$
0
0

Hi I am using run space to run some process against multiple machines and logging info into temp files, and the end of the script am concenating all the temp files into a final log files. But I notice when the script runs the temp files have neatly formatted info but after concenating into final log file the text is garbled? Is it the encoding? any way to overcome this. Also noticed the new line is not preserved and the tabs/spaces etc in the final file.

http://social.technet.microsoft.com/Forums/windowsserver/en-US/c0554226-071f-44a7-9f24-4600290d372e/runspace-threading-long-running-process?forum=winserverpowershell

I am using this function to write to tempfile. 

Function Global:WriteLogInfo
{
Param (
    [string] $Msg,
[string] $Log,
[switch] $NoConsole = $false,
[switch] $NoTimestamp = $false,
[switch] $Help
  )
  
  if (!$Msg) {
    return @{"ExitCode" = $false; "ExitMsg" = "-Msg parameter is mandatory."}
  }
  if ($NoTimestamp -eq $true) {
    $OutString = "$Msg"
  } else {
    $OutString = (get-date).ToString() + " - " + $Msg
  }
  
    if (!$Log) {
      Write-Host $OutString
    } else {
      if ($NoConsole -eq $false) {
        Write-Host $OutString
 }
      $OutString | Out-File -append $Log -encoding "UTF8"
    }  
}


Thanks



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>