Windows PowerShell

Guy recommends:
Free config generator

Solarwinds Config Generator

This CG will put you in charge of controlling changes to network routers and other SNMP devices.

Download your free Config Generator



PowerShell Scripting  - Profile.ps1

Introduction to PowerShell's Profile.ps1

DOS old timers may remember AutoExec.bat and Config.sys.  More modern Microsoft operating systems need boot.ini; all these files control the startup environment.  Well the purpose of this page is to configure the equivalent PowerShell file: profile.ps1.

PowerShell Profile.ps1 Topics

 ♣

Setting up PowerShell's Profile.ps1

Profile.ps1 location
The key to getting started is to make sure that profile.ps1 is in the correct path.

C:\Documents and Settings\All Users\Documents\PSConfiguration\profiles.ps1
alternatively
C:\Documents and Settings\%username%\Documents\PSConfiguration\profiles.ps1

Registry Setting for Scripts e.g. Profile.ps1
HKLM\Software\Microsoft\PSConfiguration\1\ShellIds \Microsoft.Management.Automation.ps1

Change the REG_SZ ExecutionPolicy from Restricted to UNRestricted or RemoteSigned (RemoteSigned as the name suggests, means that scripts from the internet must have digital certificates, however scripts on the localhost run without restriction.)  For more details of setting up profile.ps1 in the \PSConfiguration folder see here.

  ˚

Customising Profile.ps1

The principle behind profile.ps1 and other cmdlets with a msh extension is to save keystrokes into a file for reuse later.  Once you have absorbed the concept then you can truly customize your profile.ps1, merely look at examples for ideas and then adapt the most promising to set your PowerShell environment.

Working Directory.
My first task was to change the working directory from My Documents..\..\. to
D:\ scripts.  I typed set-location d:\ scripts in the Microsoft Shell - it worked.  Then I put the very same commands in profile.ps1.  At first PowerShell did not executed this instruction when it launched, this was because profile.ps1 was in the wrong folder.

Aliases
If you want to create Aliases that last for more than one session, then add them to your profile.ps1.  Experiment at the PowerShell command prompt with set-alias aliasname verb-noun pair.  When your alias works perfectly save the command into profile.ps1.

set-alias xcopy

Guy Recommends: A Free tool from SolarWinds: Config GeneratorSolarwinds LANSurveyor

Config Generator (CG) is a free tool, which puts you in charge of controlling changes to network routers and other SNMP devices.  Boost your network performance by activating network device features that you've already paid for.

Guy says that for newbies the biggest benefit of this free tool is that it will provide the impetus for you to learn more about configuring the SNMP service with its 'Traps' and 'Communities'.

Download your free copy of the Config Generator

Summary of Profile.ps1

In PowerShell RC1, profiles.ps1 does not appear in the correct folder.  After you hack the registry key called ExecutionPolicy, then you can create the msh folder in the All Users\documents.  Finally, you can add instructions to the profiles.ps1 file.

See more Microsoft PowerShell tutorials

Windows PowerShell Home  • Introduction  • Cmdlets  • Exchange 2007  • Profile.ps1  • $_.Pipeline

If you see an error of any kind, do let me know.  Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.

 *


Google

Web  This website

Review of Orion NPMGuy Recommends: Orion's NPM - Network Performance Monitor

Orion's performance monitor is designed for detecting network outages. A network-centric view make it easy to see what's working, and what needs your attention.

This utility guides you through troubleshooting by indicating whether the root cause is faulty equipment or resource overload.

Download a free trial of the Network Performance Monitor

 

Home Copyright © 1999-2010 Computer Performance LTD All rights reserved

Please report a broken link, or an error.