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.
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
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.
Example: set-alias xcopy.
Import users from a spreadsheet. Just provide a list of the
users with their fields in the
top row, and save as .csv file. Then launch this FREE utility and match
your fields with AD's
attributes, click to import the users. Optionally, you can
provide the name of the OU where the new accounts will be born.
There are also two bonus tools in this free download, and all 3 have been approved by Microsoft:
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.
If you like this page then please share it with your friends
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.
*
Custom Search
Guy Recommends: WMI Monitor and It's Free!
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.