Link to home
Start Free TrialLog in
Avatar of tolinrome
tolinromeFlag for United States of America

asked on

Powershell and different users

When I open PS I receive the "normal" default font and background colors etc, which I want to use. If I right click and (Shift + Tab) and choose "Run as different user" I receive the other profile which has a different background etc. and the color on the properties isnt available as the one on the default profile.
How can I make it where no matter which user I login with I receive the normal default profile (background color and text etc)?
Thanks.
background color and text etc)?User generated imageUser generated imageThanks.
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

run from both powershell windows:
(get-host).UI.rawui

and compare

then from one user powershell run:

notepad $profile
and save the commands to reflect the other window.

Example:
Run from one powershell windows to get the settings:
(Get-Host).UI.RawUI

From Another powershell windows run:
notepad $profile
then type in the values of those you got from first powershell window.
$a = (Get-Host).UI.RawUI
$a.BackgroundColor = "TYPE SAME COLOR AS YOU SAW IN FIRST POWERSHELL WINDOW"
$a.ForegroundColor = "YELLOW"


Reference: http://technet.microsoft.com/en-us/library/ee156814.aspx
Avatar of tolinrome

ASKER

When I do that the powershell console I want to change turns the "PS C:\Windows> to the color yellow and the background of the text DarkMagenta. I dont want this but thats what the colors say on the normal screenhot I posted.

This is what I have on the profile of the normal profile that I would like to see, but when I put it on the "different" profile it doens tmake it the same.

$a.ForegroundColor = "DarkYellow"
$a.BackgroundColor = "DarkMagenta"

Normal Profile:
PS S:\> (get-host).UI.RawUI
ForegroundColor       : DarkYellow
BackgroundColor       : DarkMagenta
CursorPosition        : 0,4
WindowPosition        : 0,0
CursorSize            : 25
BufferSize            : 120,3000
WindowSize            : 120,50
MaxWindowSize         : 120,84
MaxPhysicalWindowSize : 200,84
KeyAvailable          : False
WindowTitle           : PowerShell

Different Profile
PS C:\Windows> (get-host).UI.RawUI


ForegroundColor       : DarkYellow
BackgroundColor       : DarkMagenta
CursorPosition        : 0,4
WindowPosition        : 0,0
CursorSize            : 25
BufferSize            : 94,300
WindowSize            : 94,32
MaxWindowSize         : 94,71
MaxPhysicalWindowSize : 160,71
KeyAvailable          : False
WindowTitle           : PowerShell Scripting
Can't say I've figured all of this out yet, but here's what I've found so far.
PowerShell apparently replaces DarkYellow and DarkMagenta with the standard colors you see when set through (Get-Host).UI.RawUI, but this seems to happen only when launching PS through the shortcuts that were created during install.  This isn't true if for example you start a command prompt and then run powershell.exe from there, or if you manually create a shortcut and point it at powershell.exe.

When launching PS and selecting "Run as different user":
 - if you right-click the title bar and choose Properties, the colors you set there are persisted.  So the colors you set will be the same next time you launch using "run as".  This doesn't affect a normally launched PS session.
 - if you right-click the title bar and choose Defaults, the colors you set there don't affect the PS session, but they do affect command prompts (cmd.exe).

I've only tried the above with one different "run as" user, so I don't know how it affects others.

So I would say to open up the Properties of the window seen under "run as" and change the colors to be the same as seen when you look at the colors of the standard PS shortcut.  Click the 6th and 7th boxes (DarkMagenta and DarkYellow respectively) and change their RGB values.
Another update -
from what I see the names of colors that are available when modifying a shortcut for a console application are hard-coded.  You can also refer to these colors by number (0-15).  Try the following little script which gives a demonstration.
0..15 | % {(get-host).ui.RawUI.ForegroundColor = $_; (get-host).ui.RawUI.BackgroundColor = 15-$_ ;(get-host).ui.RawUI | select ForegroundColor,BackgroundColor}

Open in new window

Depending on how you modify the colors for the shortcut, the index number and name stay the same, but the RGB values for each can be changed.  These color values are only valid for that particular shortcut.  I don't know what shortcut (.LNK file) is used when doing a Run As.
User generated imageAttached is the properties of the two. You can see how it brings up different properties. I would like to have the settings on the left image for all powershell consoles.


It would seem though that having all the PS (shortcuts or not) pointing to one profile (the default profile) would be something one could do but seems a little complicated.
Yes, your screenshot shows exactly what I was describing above.  You can change the RBG values for any of the color options (pick a box then adjust the values).

I noticed that you asked this same question before and accepted Subsun's answer.  Did this not work for you?  I don't know of a way to set this globally, but this seems like the closest.
Thanks, I'll try your suggestion when I get a chance. It didnt work for me the previous question I asked. Thanks.

If you notice though the boxes are different, I cannot get that dark blue that I get on the left.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did it, thanks for your help and patience.