Powershell

This article was initially intended for Network Administrators.  For a large corporation that wanted to standardize their Powershell setup.

Then I realized others could benefit from this.

If you’re aware of it, in Powershell there is a file based upon your Shell called your Profile.  Powershell ISE has it’s own Profile.

All the profile IS is just a BIG dumb text file you can fill with Powershell commands, functions, settings.  Nothing more than that.

It’s typical location is sitting on %USERPROFILE%My DocumentsWindowsPowershell and is usually called Microsoft.Powershell-profile.ps1 or Microsoft.PowershellISE-profile.ps1

And it’s format is just like a PS1 file.  No real difference.   But typically you’ll fill it with functions rather than Executing programs.  But you can use yours however you want.

My task today is to show you how to create a standard profile and pass it along to other administrators.

The easiest way is to just edit your profile the way you want and store is on a network location.  Name it something unique like “OURSTANDARD.PS1”

So “assuming” we have placed the file OURSTANDARD.PS1 on a common share like \ASERVERABADLYNAMEFILESHARE all you need to do is create a NEW shortcut for Powershell launched with the following Parameters in Windows

“%SystemRoot%system32WindowsPowerShellv1.0powershell.exe -noexit -command ". ‘\ASERVERABADLYNAMEDFILESHAREOURSTANDARD.PS1’”

There! You’re done.  You only need deploy a standard Powershell Shortcut to your Network Administrators rather than trying to keep the latest profile passed about. 

And if you’re looking for a Standard Profile to work with?  Here’s something it could look like

—————– Start Profile Here ————————————-

# ABC DEF Ernie Gonzo and Cookie Monster Powershell Corporation
# Commented out so nobody can see this

FUNCTION GLOBAL:GET-PRAISE ( $Name ) { WRITE-HOST “$Name is the Greatest Administrator on the Planet!” }

WRITE-HOST ‘ABC Corporation – Powershell Administration Console’
WRITE-HOST ‘’
WRITE-HOST ‘Use GET-HELP to errrrrr….. well to GET-HELP’

————- End Profile Here ——————————————

Ok this profile is lame, really lame, COLOSALLY lame.   A little message on the screen and a new Function you can type called ‘GET-PRAISE’ to make yourself feel good.

But that’s all your profile is!  You can predefine Global functions (which could be standard Powershell scripts your normally use), common domain servers predefined or any number of things.

It’s only limited by your imagination.  And it’s easy to standardize and control. And remember…

The Power of Shell is in YOU!

Sean
The Energized Tech