Powershell – Use Profiles to Automatically Add Modules and Snappins
Automatically run commands when Powershell launches by using Powershell profiles. Kind of like .bashrc in *nix.
Open Powershell and create a profile:
New-Item -path $profile -type file –force notepad $profile
Add the commands you want to run on startup. I load the Active Directory, Exchange 2010, Systems Center Virtual Machine Manager, and Quest ActiveRoles cmdlets:
Get-Module -Name ActiveDirectory Add-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 Add-PSSnapin -Name Microsoft.Exchange.Management.Powershell.Support Add-PSSnapin -Name Microsoft.SystemCenter.VirtualMachineManager Add-PSSnapin -Name Quest.ActiveRoles.ADManagement
Save it. Now the next time you open Powershell the commands in this profile script will run.
You can get a list of modules / snappins in your Powershell instance running:
Get-PSSnapin -Registered Get-Module -ListAvailable