What’s in my profile

Recently the Scripting Guy! posted some MVPs and PFEs’ profiles. My own profile, generall fairly small was doubled after reading the PFEs’ profiles. So, I thought I would share my profile.

Initially, before reading the Scripting Guy blog, I had two functions Get-TitleBar and Set-TitleBar. These two functions have been a life saver. I generally work with several PowerShell windows open at one time. I have one for handling all my message filtering in Outlook. One for “General” stuff (usually testing) and at least 3 PowerShell windows which are used exclusively for connecting to Exchange. Using Set-TitleBar makes my life much easier as I set the titlebar to whatever project that windows is exclusively set for. So, my Outlook window is called “Outlook”, my General shell is called “General.” You get the idea.

The rest of it is all stuff I added from the blogs mentioned above. I’m looking forward to using the PSProfiler!

Here is my profile:

###############################
#
#	Functions
#
###############################


function Set-TitleBar
{

<#
.SYNOPSIS
	Sets the title bar for the current console
.DESCRIPTION
	Sets the title bar for the current console. If no parameter for TitleBar is given
	The default value of "PowerShell" is given.
.EXAMPLE
	Set-TitleBar -TitleBar "This is my title bar"
.PARAMETER TitleBar
	The string value you want placed at on the title bar.
#>
	[CmdletBinding(SupportsShouldProcess=$true)]
	param(
		[Parameter(Mandatory=$true)]
		# Username that will be provisioned a mailbox
		$TitleBar = "PowerShell"
	)

	If (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
   		[Security.Principal.WindowsBuiltInRole] "Administrator"))

	{
		$TitleBar = "Administrator: $TitleBar"
	}


	$host.UI.RAWUI.WindowTitle = $TitleBar

}




function Get-TitleBar
{

<#
.SYNOPSIS
	Gets the title bar for the current console
.DESCRIPTION
	Gets the title bar for the current console
#>

	$host.UI.RAWUI.WindowTitle

}


###############################
#
#	Commands
#
###############################

Start-Transcript -Path "C:\Data\scripts\PowerShell\Transcripts_$(Get-Date -Format yyyyMMddHHmmss).txt" | out-null

Import-Module PSProfiler | out-null

if ($(get-module psprofiler))
{
	write-host -fore yellow "Module loaded: PSProfiler"
	write-host -fore yellow "`r`nPSProfiler Example:"
	write-host -fore yellow "Measure-Script -Path c:\script.ps1"
	write-host -fore yellow "More info: http://www.powershellmagazine.com/2013/05/13/measuring-powershell-scripts/"
	write-host -fore yellow "More info: http://code.msdn.microsoft.com/Script-Line-Profiler-Sample-80380291/sourcecode?fileId=70887&pathId=217486489"
	write-host "`r`n`r`n"
}

if ( $(test-Path C:\data\scripts\PowerShell) )
{
	Set-Location C:\data\scripts\PowerShell
}

Leave a Reply