DevHawk
Passion * Technology * Ruthless Competence
Weblog
Archives
Custom Content
TechieWife
DevHawk Designs
Monday, July 28, 2008
« DevHawk's Slightly Useful Powershell Con...
|
Home
|
Pushed the Wrong Button »
Some Powershell Scripts
By popular demand, I uploaded a bunch of my scripts to
my SkyDrive
. Included are:
Set Powershell Home
- this is actually a zip file that contains the profile redirect script. Unzip this in your Documents folder and change the path in Microsoft.PowerShell_profile to where ever you want your profile and home directories to live.
_profile
- my "real" profile script. Note, the su function requires the
Script Elevation PowerToys
in order to work. Also, all the various aliases are hard coded to their location on my machine. You'll probably want to change them.
prompt
- my prompt script
prepend-path
- a script to add a directory to start of my path
append-path
- like above, but adds the directory to the end of the path
append-path-perm
- like append-path, but permanently updates the path in the registry
Enjoy.
Posted By
Harry Pierson
at 4:26 PM Pacific Daylight Time
Comments [5]
PowerShell
Wednesday, July 30, 2008 9:09:10 AM (Pacific Standard Time, UTC-08:00)
From profile.ps1:
> cmd.exe /c color 4f
You can control the colours that PSH's console host uses by assigning to the members of $Host.PrivateData.
E.g. $Host.PrivateData.WarningForegroundColor = "green"
(Each is of type [System]::ConsoleColor)
Richard
Wednesday, July 30, 2008 10:32:21 AM (Pacific Standard Time, UTC-08:00)
@Richard, Thanks. However, that doesn't appear to let me set the background for the command shell window as a whole though. Only, the Warning, Error, Debug, Verbose and Progress fore & background colors. I can see the value of that, but my goal with that line of script is to set the entire background to red.
DevHawk
Thursday, July 31, 2008 8:42:06 AM (Pacific Standard Time, UTC-08:00)
If you want to change the settings for the console, use $host.ui.rawui.foregroundcolor and .background color. I have functions like this:
function green { $host.ui.rawui.foregroundcolor = "Green"; $host.ui.rawui.backgroundcolor = "Black" }
function yellow { $host.ui.rawui.foregroundcolor = "Yellow"; $host.ui.rawui.backgroundcolor = "Black" }
Tommy Williams
Friday, August 01, 2008 5:41:04 AM (Pacific Standard Time, UTC-08:00)
> However, that doesn't appear to let me set the background for the command shell window as a whole though
Follow it with a Clear-Host
My current^h finally implemented elevated PSH (use scope modifiers so don't just create a local variable in the condition block containing this):
$host.UI.RawUI.Backgroundcolor="DarkGray"
$host.UI.RawUI.Foregroundcolor="Red"
clear-host
write-host "`n** Elevated Session **`n" -foreground DarkRed -background Yellow
$global:ConsolePromptColour = "Red" # Override prompt function's default
$global:ConfirmPreference = "Medium"
Richard
Friday, August 01, 2008 12:10:52 PM (Pacific Standard Time, UTC-08:00)
Thanks Tommy and Richard! I updated my _profile script to use instead of $host.UI.RawUI.Backgroundcolor cmd.exe /c color.
DevHawk
Comments are closed.
Email DevHawk
Subscribe to DevHawk
Call DevHawk
DevHawk on Twitter
DevHawk on Facebook
DevHawk on WLM
DevHawk
World Tour 2008
Upcoming Dates
SoCal Code Camp
PDC08
patterns & practices
Summit 2008
RayTracer
Blog Archive
December, 2008 (1)
November, 2008 (20)
October, 2008 (4)
September, 2008 (4)
August, 2008 (8)
July, 2008 (16)
June, 2008 (1)
May, 2008 (6)
April, 2008 (12)
March, 2008 (18)
February, 2008 (14)
January, 2008 (14)
2007 (245)
2006 (174)
2005 (150)
2004 (252)
2003 (262)
Recent Bookmarks
Tags
.NET Framework (2)
ADO.NET (5)
Agile (7)
AJAX (3)
Architecture (284)
Guidance (6)
Interop (2)
Modelling (61)
Patterns (7)
Process (4)
SOA (93)
Web Services (5)
ASP.NET (24)
Battlestar Galactica (3)
BI (2)
BizTalk (4)
Blogging (115)
dasBlog (11)
Podcasting (4)
BPM (1)
C# (10)
C++ (4)
Capitals (5)
CardSpace (3)
CLR (2)
College Football (10)
Comedy Central (1)
Community (81)
Concurrency (6)
Consumer Electronics (1)
Database (13)
Dependency Injection (2)
Development (117)
C Plus Plus (1)
Embedded (5)
Lanugages (37)
Media (2)
P2P (11)
Rotor (1)
SharePoint (6)
SOP (3)
DIY (1)
DLR (16)
Domain Specific Languages (13)
Durable Messaging (5)
Dynamic Languages (10)
Dynamic Silverlight (1)
Education (3)
Enterprise 2.0 (1)
Entertainment (14)
ETech (15)
F# (51)
Functional Programming (17)
Game Development (2)
Guidance Automation (3)
Hardware (8)
HawkEye (3)
Hockey (29)
Home Electronics (1)
Home Network (5)
Humor (5)
IASA (1)
Idempotence (3)
infrastructure (5)
Instrumentation (4)
Integration (2)
IronPython (45)
IronRuby (12)
Java (2)
Job (3)
LINQ (23)
Live Mesh (2)
Lost (1)
Master Data Management (1)
Media 2.0 (6)
Microsoft (30)
MIX06 (2)
Mobile Phone (1)
Monads (5)
Morning Coffee (172)
Object Oriented (4)
Office (5)
Open Source (5)
Open Space (2)
Operations (3)
Other (135)
Art (1)
Books (1)
Family (31)
Games (18)
General Geekery (26)
Home Theater (1)
Movies (23)
Music (20)
Politics (3)
Society (1)
Sports (37)
Working at MSFT (15)
Parallel Programming (3)
Parsing Expression Grammar (16)
patterns & practices (2)
PDC08 (5)
Politics (47)
PowerPoint (2)
PowerShell (34)
Presentation (5)
Projects (1)
HawkWiki (1)
Python (4)
Quote of the Day (4)
Refactoring (1)
Research (2)
REST (18)
Reuse (5)
Robotics (2)
Rock Band (4)
Rome (5)
Ruby (23)
Ruby on Rails (1)
Sci-Fi (2)
Scripting (4)
Security (3)
Service Broker (14)
SharePoint (2)
Silverlight (18)
Social Software (1)
Software + Services (2)
Software Design (1)
Software Factories (11)
Software Industry (1)
Spark (1)
SQL Server (2)
Stephen Colbert (1)
TechEd (7)
TechEd06 (1)
TechRec League (1)
Television (6)
Travel (6)
Unified Client (1)
Unit Testing (4)
USC (1)
UX (1)
Virtual PC (2)
Visual Basic (1)
Visual Studio (20)
Volta (2)
Washington Capitals (34)
WCF (31)
Web 2.0 (65)
Web Services (5)
WF (21)
Windows Live (23)
WPF (7)
Xbox (1)
Xbox 360 (53)
XML (11)
XNA (14)
Zune (4)
Disclaimer
: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion.
Sign In