Does anyone have any idea how I could fix this in my script? I would just like for it to display “Test complete, blah blah blah” without it showing the last command that I ran (in this case the test connection 8.8.8.8). Here’s what I have in my ps1 file:
test-netconnection 8.8.8.8|Out-File -FilePath .\GTS_Log.txt -Append
cls
Write-Host “Test Complete, you may now close this window, and check your logs!” -ForegroundColor white -BackgroundColor Red
Write-Host “The logs are text files, located in the same directory where this script exists.” -ForegroundColor white -BackgroundColor Red
Write-Host “” -ForegroundColor white -BackgroundColor Red
Write-Host “” -ForegroundColor white -BackgroundColor Red
Write-Host “” -ForegroundColor white -BackgroundColor Red
powershell -noexit
Any advice would be greatly appreciated as this has been driving me nuts!!
How are you calling the script? Seems like you’re potentially calling it externally or double clicking the file maybe? and its opening your PS window and immediately running. Why not just call the script from PS directly? You also won’t need powershell -noext then either.
You can hide the copyright message with -NoLogo. You might want to suppress other output too so investigate the various switches with powershell.exe /?
Personally, I think I’d wait for a keypress or use a popup rather launch another process:
Add-Type -AssemblyName PresentationCore,PresentationFramework
$Title = 'Finished!'
$Message = @"
Test Complete.
Log files can be found in $PSScriptRoot
"@
[System.Windows.MessageBox]::Show($Message,$Title)