Learn how to get Free YouTube subscribers, views and likes
Get Free YouTube Subscribers, Views and Likes

Getting started with PowerShell Profiles

Follow
Shane Young

In this video, we look at how to solve the most common complaint I get about my videos using a PowerShell Profile. With Profiles, you can have cmdlets like StartTranscript run everytime you open a new session. Pretty cool stuff that is easy to implement once I show you the basics.

Cmdlets we cover:
* Get_PSReadLineOption
* $profile
* testpath
* NewItem

Video on installing PSReadLine
   • Update PowerShell for Windows 7 and W...  

#Color Function Script
function ShowColors( ) {
$colors = [Enum]::GetValues( [ConsoleColor] )
$max = ($colors | foreach { "$_ ".Length } | MeasureObject Maximum).Maximum
foreach( $color in $colors ) {
WriteHost (" {0,2} {1,$max} " f [int]$color,$color) NoNewline
WriteHost "$color" Foreground $color
}
}

#Everything in my profile
StartTranscript | OutNull
SetPSReadlineOption TokenKind String ForegroundColor Yellow
IF (([Security.Principal.WindowsPrincipal] ` [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
$host.ui.RawUI.WindowTitle = "I love PowerShell Running as ADMINISTRATOR"
}
Else
{
$host.ui.RawUI.WindowTitle = "I love PowerShell"
}
cd c:\demo

For support, training, or more information about PowerShell check out http://www.boldzebras.com

posted by Gladkovjp