title: Is there a way to prevent new line after 80 characters in output created by powershell script executed via ssh from linux?
body: <p>I'm developing Linux expect script that:</p>
  
  <ol>
  <li>makes ssh connection to Windows host command prompt.</li>
  <li>Accesses powershell.</li>
  <li>Navigates to existing folder on windows and invokes a powershell script.</li>
  <li>Power shell script saves output to a text file.</li>
  </ol>
  
  <p>When I run Linux script using Java, the powershell is executed successfully. However, output file created by powershell script is only 80 chars wide. 
  When I run the script manually (via terminal and pass arguments manually), the output file is created without new lines after 80 chars.</p>
  
  <p>I've tried to change encoding to utf8 and utf16 in powershell, but it doesn't resolve the issue</p>
  
  <pre><code>Get-MsolDomainFederationSettings -DomainName "example.com" | Out-File "C:\temp\fedSettings.txt"
  
  Get-MsolDomainFederationSettings -DomainName "example.com" | Format-List * | Out-File "C:\temp\fedSettings.txt" -Encoding utf8
  
  Get-MsolDomainFederationSettings -DomainName "example.com" | Format-List * | Out-File "C:\temp\fedSettings.txt" -Encoding utf16
  </code></pre>
  
  <p>I have also, ensured that the expect scripts do not have any Ctrl+M characters.</p>
  
  <p>This is script that I execute via java ProcessBuilder</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/expect
  set timeout 20
  
  #This expect script script invokes an existing script in Windows Powershell on a Windows Host via SSH from Linux.
  
  set WINDOWS_HOST_NAME [lindex $argv 0]
  set WINDOWS_USER [lindex $argv 1]
  set WINDOWS_PASSWORD [lindex $argv 2]
  set WINDOWS_FOLDER_PATH [lindex $argv 3]
  set SCRIPT_FILE_NAME [lindex $argv 4]
  
  spawn ssh $WINDOWS_USER@$WINDOWS_HOST_NAME
  
  expect "yes/no" { 
      send "yes\r"
      expect "*?assword" { send "$WINDOWS_PASSWORD\r" }
      } "*?assword" { send "$WINDOWS_PASSWORD\r" }
  
  expect "*$WINDOWS_USER*"
  send "powershell\r";
  send "cd $WINDOWS_FOLDER_PATH\r"
  
  send "\.\\$SCRIPT_FILE_NAME\r"
  
  send "exit\r"
  send "exit\r"
  
  interact
  </code></pre>
  
  <p>This is the powershell script that exists in windows and gets invoked by linux script.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$AdminUser = "someone.com"
  $Pswd = Get-Content "C:/creds/cred1" | ConvertTo-SecureString
  $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminUser, $Pswd
  $dom = "example.com"
  $dateTime = Get-Date -f "MMddyyyy_HHmm"
  
  Connect-MsolService -Credential $cred
  
  Get-MsolDomainFederationSettings -DomainName $dom | Format-List * | Out-File "C:\temp\fedSettings.txt"
  $filenameFormat = "fedSettings_$(Get-Date -Format "MMddyyyy_HHmm").txt"
  Rename-Item -Path "C:\temp\fedSettings" -NewName $filenameFormat
  </code></pre>
  
  <p>I'm expecting that when PowerShell creates an output file, the new line is introduced only if content/data of the line is complete.
  However, the output file created is limited to only <code>80 chars</code> when executed via java/automated. 
  But, when I execute the expect script manually, then, the file is fine.</p>