Powershell

In Powershell there is a VERY use to feature that many of us didn’t touch (*especially those of use NEW to Powershell*)

It’s called your “Profile”

The Profile is just settings and Functions that are SPECIFIC to a Powershell session.  Most of the time you will see them in use by software such as “Quest ActiveRoles Management Shell”.  When you see “Custom Management Shells” such as the Exchange Server 2007 and DPM Shell, those are just really customized profiles for the most part.

 

So how can YOU make a profile in Powershell that meets your daily needs?

Very easy in fact.   You won’t be surprise either, it’s dead simple too!

Your personal profile be default does not exist BUT the variable to point where it is DOES.  All YOU have to do is run this simple command

NEW-ITEM –ITEMTYPE File –PATH $PROFILE –FORCE

And you now have a blank profile.

By launching NOTEPAD $PROFILE you can edit it and add useful features to your Powershell session.

For example, is there a particular script you use DAILY or functions you would like to have native your Powershell session?

Turn them into Functions in Powershell and add it to your profile.  It’s as simple as copy paste!

Do you have going between Quest and Exchange 2007 and would like it all as ONE shell?

Put the ADD-PSSNAPIN for each feature as the top lines of your profile.

How about something as simple as “I want my Shell each and everyday to greet me with a Cheery HELLO!”

Well you can do that to! Make the last line (or the first as you prefer)

Here’s a sample profile so you can understand the syntax.  It’s not really any different from a PS1 file, in some ways it’s a LOT like a PS1 file that runs on the startup of Powershell

—————– Sample Profile ———————–

# Add Snapins

ADD-PSSNAPIN Quest.ActiveRoles.AdManagement

# Say Hello to the nice person

WRITE-HOST “Hello and Goodday to you Glorius Administrator”
WRITE-HOST “I am your Powershell Administration Session.”
WRITE-HOST “Your wish is my command”

#Define a useful function

function global:OUT-HAPPYMESSAGE {
WRITE-HOST “I am the King of my Universe, all shall run away from me…”
}

#Make an Alias

NEW-ALIAS O INVOKE-EXPRESSION

—————– Sample Profile ———————–

 

So with this very simple profile My Powershell session will now start like this

image

As you can see I now Have a new Custom function called “OUT-HAPPYMESSAGE” I can run anytime to make myself feel good and mighty.

I can now Open Files and launch their respective applications.

I can also access my Quest Commandlets and be more Productive and leave work earlier and go…… I mean MAKE THINGS FASTER SO I CAN WORK HARDER! (did my boss see that?)

All in all not difficult to use, to change or to share (As it’s just a text file under the

%USERPROFILE%DocumentsWindows Powershell

Folder that you can copy onto other systems as well.

Powershell, Live the good Life for free

 

Sean
The Energized Tech