none
Where is title set RRS feed

  • Question

  • When I open a PS console using 'Run as Administrator', the title is changed.  I know you set stuff like that using this.  My question is, where is it done in this case?  I checked all the profiles I know of, and no luck.
    GregM
    Wednesday, March 9, 2011 2:52 PM

All replies

  • Show your ${fucntion:prompt} . 
    Wednesday, March 9, 2011 2:55 PM
  • I'm not looking at the prompt, but the title bar.  function:prompt is standing.  Looks like

    $(if (test-path variable:/PSDebugContext) { '[DBG]: ' } else { '' }) + 'PS ' + $(Get-Location) + $(if ($nestedpromptlev
    el -ge 1) { '>>' }) + '> '
    

    GregM
    Wednesday, March 9, 2011 3:42 PM
  • (get-host).ui.rawui.windowtitle = "new title here"

    Wednesday, March 9, 2011 3:48 PM
  • I'm not looking at the prompt, but the title bar.  function:prompt is standing.  Looks like

    $(if (test-path variable:/PSDebugContext) { '[DBG]: ' } else { '' }) + 'PS ' + $(Get-Location) + $(if ($nestedpromptlev
    el -ge 1) { '>>' }) + '> '
    

    GregM

    1) Compare prompt with Run as and without.

    2) $profile | gm -MemberType noteproperty | % {gc $profile.($_.name)} | select-string WindowTitle 

    3) Show your profile.

    4)Loaded there any scripts or modules?

    Wednesday, March 9, 2011 3:54 PM
  • I'm not looking to set it.  I know that. It's outlined in one of the links in my original post.

    I'm looking for how it's set when I open a console.


    GregM
    Wednesday, March 9, 2011 3:59 PM
  • 1) The same

    2) $profile points to 'C:\Users\setup\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1' which does not exist (in either console)

    3) My profile doesn't do anything with (get-host).ui.rawui.windowtitle.  In fact, as the windows are 'opening' and before the profiles have loaded, the title is already changed.

    4) See answer 3.

    This is normal PS behavior.  That's not the problem.  I just know there is default magic somewhere, and I'm attempting to locate where.


    GregM
    Wednesday, March 9, 2011 4:02 PM
  • I think its just something done by the app, for example, as Kazun pointed out, the prompt function. if you don’t set it (empty profile), there is a default, which I assume is hard coded. my guess is that the title is something like that as well.

    my experience with the console and even ISE is that it will load the defaults and then its up to you to change them if you want it differently. there is no config file that it checks.. its basically the opposite of most things.. most things will check a config and load those options that are set and if they arent set, load the default... powershell seems to load the defaults and then if you want them changed you can do that (via a profile)

    Wednesday, March 9, 2011 4:04 PM
  • Show your profile and output [environment]::GetCommandLineArgs().
    Wednesday, March 9, 2011 4:08 PM
  • Profile -

    "Welcome $env:username  PS Version: " + (get-itemproperty -path "HKLM:\Software\Microsoft\PowerShell\1\PowerShellEngine").RuntimeVersion
    set-location Y:\MyModules\SpSetup 
    

    [System.Environment]::GetCommandLineArgs()

    C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe

     


    GregM
    Wednesday, March 9, 2011 4:14 PM
  • My guess is that the PowerShell code prepends "Administrator: " to the title if the process token includes the Administrators group.  One bit of evidence for this is that it happens even if PowerShell.exe is started with the -noprofile option.
    Wednesday, March 9, 2011 4:16 PM
  • I suspect you are right. I was just trying to find out where this magic happens.


    GregM
    Wednesday, March 9, 2011 4:18 PM