Ryan
asked on
Windows PowerShell text color
Whenever I type text in the powershell window it is yellow. I have tried adjusting the colors in properties, but it still comes out yellow. How do I change it to white?
ASKER
doesn't seem to be working. I don't know why not.
It's not "yellow whenever you type text". Try, for example
Since Windows 8, PS comes by default with the PSReadline module. PSReadline is responsible for the automatic syntax highlighting, which is why the old way doesn't work anymore.
You need to change color options using the cmdlet Set-PSReadlineOption.
Enter
These changes are only valid for the current PS session (so you can test as much as you want - just start a new shell to be back at the defaults).
To make them permanent, you need to add the change commands to your profile.
See, for example, here:
https://blogs.technet.microsoft.com/heyscriptingguy/2012/05/21/understanding-the-six-powershell-profiles/
https://www.red-gate.com/simple-talk/sysadmin/powershell/persistent-powershell-the-powershell-profile/
$a = "A" * 10
Note that there are (in all likelihood) several colors involved (green, something like petrol, white).Since Windows 8, PS comes by default with the PSReadline module. PSReadline is responsible for the automatic syntax highlighting, which is why the old way doesn't work anymore.
You need to change color options using the cmdlet Set-PSReadlineOption.
Enter
Get-Help Set-PSReadlineOption -ShowWindow
then enter "color" into the search field to highlight the arguments defining the colors.These changes are only valid for the current PS session (so you can test as much as you want - just start a new shell to be back at the defaults).
To make them permanent, you need to add the change commands to your profile.
See, for example, here:
https://blogs.technet.microsoft.com/heyscriptingguy/2012/05/21/understanding-the-six-powershell-profiles/
https://www.red-gate.com/simple-talk/sysadmin/powershell/persistent-powershell-the-powershell-profile/
doesn't seem to be working. I don't know why not.
Windows 10 perhaps? Run DISM followed by SFC to see if that resets Powershell.
DISM:
Open cmd.exe with Run as Administrator.
DISM.exe /Online /Cleanup-Image /Restorehealth
Now in the same Command Window, run SFC /SCANNOW. Allow to complete
Now restart and test.
Windows 10 perhaps? Run DISM followed by SFC to see if that resets Powershell.
DISM:
Open cmd.exe with Run as Administrator.
DISM.exe /Online /Cleanup-Image /Restorehealth
Now in the same Command Window, run SFC /SCANNOW. Allow to complete
Now restart and test.
Slight correction: PSReadline is only included by default since Windows 10.
This has some screenshots that should look familiar; "yellow" is a command, btw. (cmdlet or external):
Use PSReadLine for More Efficient PowerShell Console
https://blogs.technet.microsoft.com/heyscriptingguy/2015/04/28/use-psreadline-for-more-efficient-powershell-console/
This has some screenshots that should look familiar; "yellow" is a command, btw. (cmdlet or external):
Use PSReadLine for More Efficient PowerShell Console
https://blogs.technet.microsoft.com/heyscriptingguy/2015/04/28/use-psreadline-for-more-efficient-powershell-console/
Also check what theme you are using. I am using a classic theme with a blue background and Powershell is working like I think it should.
ASKER
Expert Comment
by:oBdA
ID: 42306767
19h
Get-Help Set-PSReadlineOption -ShowWindow
-------------------------- ---------- ---------- --------
The above command shows the different cmdlets available, but unfortunately I'm not a programmer so I just need the command to change the color of the text I type to white so I can add it to my profile. I still want the text of the errors to be red. All other text should be white. Thank you.
by:oBdA
ID: 42306767
19h
Get-Help Set-PSReadlineOption -ShowWindow
--------------------------
The above command shows the different cmdlets available, but unfortunately I'm not a programmer so I just need the command to change the color of the text I type to white so I can add it to my profile. I still want the text of the errors to be red. All other text should be white. Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works great! I will add that line of code to my profile. Thank you very much!
ASKER
My current profile looks like this:
$a = (Get-Host).UI.RawUI
$a.BackgroundColor = "black"
$a.ForegroundColor = "white"
$env:path += ";C:\My Documents\PowerShell BACKUP\scripts"
Remove-Module PSReadline
cls
but the text is still yellow unless I enter:
Remove-Module PSReadline
after starting Powershell as the administrator
Then it works just fine, but it does not seem to work by adding it to the profile. Sorry, I thought that this would fix the problem, but apparently it hasn't. Does the line of code need to go in a particular location in the profile? Thank you.
$a = (Get-Host).UI.RawUI
$a.BackgroundColor = "black"
$a.ForegroundColor = "white"
$env:path += ";C:\My Documents\PowerShell BACKUP\scripts"
Remove-Module PSReadline
cls
but the text is still yellow unless I enter:
Remove-Module PSReadline
after starting Powershell as the administrator
Then it works just fine, but it does not seem to work by adding it to the profile. Sorry, I thought that this would fix the problem, but apparently it hasn't. Does the line of code need to go in a particular location in the profile? Thank you.
Then try this instead:
[Microsoft.PowerShell.TokenClassification].GetEnumValues() | % { Set-PSReadlineOption -TokenKind $_ -ForegroundColor ([console]::ForegroundColor)}
ASKER
When I put that line of code into the profile the text is still yellow when I type. same thing.
Can't reproduce, sorry. Both work just fine for me when I add them to
"${env:USERPROFILE}\Documents\WindowsPowerShell\Profile.ps1"
Where exactly are you adding the commands?
ASKER
The complete profile is:
$a = (Get-Host).UI.RawUI
$a.BackgroundColor = "black"
$a.ForegroundColor = "white"
$env:path += ";C:\My Documents\PowerShell BACKUP\scripts"
[Microsoft.PowerShell.Toke nClassific ation].Get EnumValues () | % { Set-PSReadlineOption -TokenKind $_ -ForegroundColor ([console]::ForegroundColo r)}
cls
$a = (Get-Host).UI.RawUI
$a.BackgroundColor = "black"
$a.ForegroundColor = "white"
$env:path += ";C:\My Documents\PowerShell BACKUP\scripts"
[Microsoft.PowerShell.Toke
cls
ASKER
I just want all the text (except errors which are red) to be white. I don't know why the text is appearing as yellow as I don't know of anything that I have changed. It may have been changed by a windows update. I am an advanced home user and not a network admin so the scripts I write are very basic.
Example:
$b = read-host "Input filename to backup"
copy-item "C:\My Documents\$b" -destination "E:\My Documents"
copy-item "C:\My Documents\$b" -destination "F:\My Documents"
copy-item "C:\My Documents\$b" -destination "C:\Users\Ryan\Google Drive\My Documents"
I do appreciate all your help. I've been working with computers for almost 30 years and sometimes they just don't work as they should. Thanks again and bye for now.
Example:
$b = read-host "Input filename to backup"
copy-item "C:\My Documents\$b" -destination "E:\My Documents"
copy-item "C:\My Documents\$b" -destination "F:\My Documents"
copy-item "C:\My Documents\$b" -destination "C:\Users\Ryan\Google Drive\My Documents"
I do appreciate all your help. I've been working with computers for almost 30 years and sometimes they just don't work as they should. Thanks again and bye for now.
1. Open Powershell with Run as Administrator (just to be sure)
2. Click on the little icon top left of the Powershell title bar.
3. Select Defaults.
4. Select Color Tab.
5. Select your color and OK out and see if it is now saved.