Add one or more PowerShell snap-ins to the current console.
Syntax
Add-PSSnapin [-name] string[] [-passThru] [CommonParameters]
Key
-name string[]
Name of each PSSnapIn to add to the current console
e.g. Microsoft.Exchange or MyCompany.User.
-passThru
Pass the object created by this cmdlet through the pipeline.
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.
Changing the available cmdlets and providers by adding or removing snap-ins will only affect the current console, unless Export-Console is used to save the console. Built-in snap-ins that are installed with PowerShell cannnot be removed.
Examples
Add the Microsoft Exchange and Microsoft AD Directory Services snap-ins to the current console:
PS C:>add-PSSnapIn Microsoft.Exchange,Microsoft.Windows.AD
Add the Quest Active directory snap-ins to the current console:
PS C:> Add-PSSnapin Quest.ActiveRoles.ADManagement
Add all the registered Windows PowerShell snap-ins to the console:
PS C:> get-pssnapin -registered | add-pssnapin -passthru
Save the console configuration
To save the configuration of the current console, (including any extra snap-ins that are loaded) to a (.psc1) console file use Export-Console.
PS C:> export-console C:\SS64.psc1
Restore the console configuration
To open a powershell console with a saved console configuration, start PowerShell with the -PsConsoleFile parameter.
PS C:> powershell.exe -psconsolefile C:\SS64.psc1
"When the character of a man is not clear to you, look at his friends." - Japanese Proverb
Related:
Export-Console - Export console configuration to a file
get-PSSnapin - List PowerShell snap-ins on this computer
Remove-PSSnapin - Remove PowerShell snap-ins from the console
© Copyright SS64.com 1999-2013
Some rights reserved