Console Display Changes - $Host is a special variable that is a reference to the current
console object
You can easily change the background and foreground colors to suit your preferences.
To change the background color to magenta
$Host.UI.RawUI.BackgroundColor=”magenta”
To change the foreground color $Host.UI.RawUI.ForegroundColor=”blue”
To view your windows size specs: $Host.UI.RawUI.WindowSize
Will not change values
$Host.UI.RawUI.WindowSize.Width = 110
$Host.UI.RawUI.WindowSize.Height = 40
You change the window size by changing the value:
$size = $Host.UI.RawUI.WindowSize
$size.Width = 100
$size.Height = 25
$Host.UI.RawUI.WindowSize = $size
Profiles
$profile shows default profile – something similar to the following
C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.
Create a Profile
Create the WindowsPowerShell folder in your My Documents folder if it doesn’t already exist.
Create a blank text file using Notepad in the location pointed to by $profile. This profile is
really just a PSH script enter something like this…..
$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
Saved the File with .ps1 extension.
NOTE: By default, Windows PowerShell won’t let you run anyscript (not even your profile)
unless it has been signed using a trusted certificate issued either by a Certificate Authority
or a self-generated certificate using the
Microsoft .NET Framework Software Development Kit (SDK). You can change this by running
Set-ExecutionPolicy RemoteSigned