header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Unable to Customize Powershell Console
Last Post 23 Jul 2010 10:11 AM by Chris. 3 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
jibberjabberUser is Offline
New Member
New Member
Posts:2
Avatar

--
22 Jul 2010 06:44 AM
    I am reading Windows Powershell™ 2 For Dummies® and chapter 2 explains how to customize the powershell console.

    Created a file Microsoft.PowerShellISE_profile.ps1 with the following contents:

    $Shell = $Host.UI.RawUI
    $Shell.WindowTitle="PowerShell Obeys Me"
    $Shell.BackgroundColor="White"
    $Shell.ForegroundColor="Blue"
    $size = $Shell.WindowSize
    $size.width=120 $size.height=55
    $Shell.WindowSize = $size
    $size = $Shell.BufferSize
    $size.width=120
    $size.height=5000
    $Shell.BufferSize = $size
    Clear-Host

    When I load the powershell_ise, it does change the window title, background, foreground colors, but I also receive the following errors:

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Users\[user]\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1:6 char:7 + $size. <<<< width=120 + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound

    Property 'height' cannot be found on this object; make sure it exists and is settable. At C:\Users\[user]\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1:7 char:7 + $size. <<<< height=55 + CategoryInfo : InvalidOperation: (height:String) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound

    Exception setting "WindowSize": "Cannot convert null to type "System.Management.Automation.Host.Size"." At C:\Users\[user]\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1:8 char:8 + $Shell. <<<< WindowSize = $size + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException

    How do I fix these errors?
    George HowarthUser is Offline
    Basic Member
    Basic Member
    Posts:360
    Avatar

    --
    22 Jul 2010 07:17 AM
    $host.UI.RawUI.WindowSize isn't set in ISE, its only set with a PowerShell console instance.
    jibberjabberUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    22 Jul 2010 09:59 AM
    Thank you.

    ChrisUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    23 Jul 2010 10:11 AM
    Yeah, you were trying to edit the Microsoft.PowerShellISE_profile.ps1 instead of the Microsoft.PowerShell_profile.ps1.  Tripped me up too.  The ISE and the command shell both have their own profile in the same location that can be modified.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer