Describe the bug
The current refactored profile (v1.04) prints visual elements, help messages, and telemetry/update checks during non-interactive shell sessions. When attempting to use scp or rsync from a remote machine (e.g., a Mac or Linux box) to the Windows host, these tools fail with the error: Received message too long or protocol error: unexpected tag.
This happens because the profile's output is injected into the data stream, which the remote client tries to interpret as file metadata.
To Reproduce
- Install the CTT PowerShell profile on a Windows host.
- From a remote machine, attempt to copy a file using SCP:
scp file.txt user@windows-host:/C:/Destination/
- See error:
scp: Received message too long ... or Ensure the remote shell produces no output for non-interactive sessions.
Expected behavior
The profile should detect if it is being loaded in a non-interactive or redirected session and return or exit immediately before any logic or Write-Host commands run.
Proposed Solution
Add a "Short Circuit" check at the very top of Microsoft.PowerShell_profile.ps1:
# Check for non-interactive/redirected sessions to prevent breaking SCP/RSYNC
if ($Host.Name -ne "ConsoleHost" -or [System.Console]::IsOutputRedirected) {
return
}
Additional Context
Users using edit-profile (creating a profile.ps1) currently cannot easily bypass the main profile's update checks and Show-Help logic because the main profile loads those elements before or during the override process. A global check at the top of the hashed file would solve this for all users.