title: How to write the console output from powershell to a text file
body: <p>I have tried many solutions to get the output of powershell to a text file so I can read it.  I can't get the console output to stop at the end so I can read it and I can't get it to write out a file. With this code a text file isn't written.  Windows 10 1903</p>
  
  <pre><code>:: This will Remove all Appxpackages
  ::
  $AppsList = 'Microsoft.3DBuilder', 
  'Microsoft.BingFinance', 
  'Microsoft.BingNews',
  'Microsoft.BingSports', 
  'Microsoft.MicrosoftSolitaireCollection',
  'Microsoft.People', 
  'Microsoft.Windows.Photos', 
  'Microsoft.WindowsCamera',
  'microsoft.windowscommunicationsapps', 
  'Microsoft.WindowsPhone',
  'Microsoft.WindowsSoundRecorder', 
  'Microsoft.XboxApp', 
  'Microsoft.ZuneMusic',
  'Microsoft.ZuneVideo', 
  'Microsoft.Getstarted', 
  'Microsoft.WindowsFeedbackHub',
  'Microsoft.XboxIdentityProvider', 
  'Microsoft.MicrosoftOfficeHub',
  'Fitbit.FitbitCoach',
  'ThumbmunkeysLtd.PhototasticCollage'
  
  C:\Batch\PSEXEC.EXE  -s powershell -c 
  Start-Transscript -Path 'C:\RemoveAllAppxPackages.txt'
  ForEach ($App in $AppsList){
      $PackageFullName = (Get-AppxPackage -AllUsers $App).PackageFullName
      $ProPackageFullName = (Get-AppxProvisionedPackage -AllUsers | where {$_.Displayname -eq                         $App}).PackageName
  write-host $PackageFullName
  Write-Host $ProPackageFullName
  if ($PackageFullName){
      Write-Host "Removing Package: $App"
      remove-AppxPackage -package $PackageFullName -AllUsers  &gt; C:\RemoveAllAppxPackages.txt
  )   pause
     }
  
      else{
          Write-Host "Unable to find package: $App"  &gt; C:\RemoveAllAppxPackages.txt
     pause
      }
  
      if ($ProPackageFullName){
          Write-Host "Removing Provisioned Package: $ProPackageFullName"
          Remove-AppxProvisionedPackage -online -packagename $ProPackageFullName  &gt;             C:\RemoveAllAppxPackages.txt
     pause
      }
  
      else{
          Write-Host "Unable to find provisioned package: $App"  &gt; C:\RemoveAllAppxPackages.txt
     pause
      }
  }
  Pause
  Stop-Transcript
  </code></pre>