Problem
You want to load PowerShell with a set of additional snapins, but do not want to modify your (or the user’s) profile.
Solution
Once you register a snapin on your system, you can add its snapin identifier to a PowerShell console file to load it. When you specify that file as the PsConsoleFile parameter of PowerShell.exe, PowerShell loads all snapins defined by the console file into the new session.
Save the list of currently loaded snapins to a console file:
ExportConsole Filename.psc1
Load PowerShell with the set of snapins defined in the file Filename.psc1:
PowerShell PsConsoleFile Filename.psc1
Discussion
PowerShell console files are simple XML files that list the identifiers of alreadyinstalled snapins to load. A typical console file looks like
Example 111. A typical PowerShell console file
<?xml version="1.0" encoding="utf8"?>
<PSConsoleFile ConsoleSchemaVersion="1.0"> <PSVersion>1.0</PSVersion> <PSSnapIns>
<PSSnapIn Name="CustomSnapin" /> <PSSnapIn Name="SecondSnapin" /> </PSSnapIns> </PSConsoleFile>
Console files should be saved with the file extension .psc1.
Although it is common to load the console file with PowerShell’s commandline options (in scripts and automated tasks), you can also doubleclick on the console file to load it interactively.