Windows PowerShell PSSnapin
A PowerShell snapin contains extra cmdlets, usually for a specialist purpose such as Quest's Active directory family of cmdlets. The trick is to append, inject, register, or wire up PowerShell to accept additional verb-Noun pairs from other providers.
PowerShell Topics for Add-PSSnapin
Secondly, to get any action from the additional Quest active directory snap-In you need to logon as administrator of a domain. I downloaded and installed the snap-In, then I ran the following command on a Domain Controller. I say again, if you don't have a domain, research the internet for alternative snap-Ins.
# Simple Instruction for PowerShell snapin
Note 1: Please navigate to wherever you downloaded the snap-In. I used the c:\ root for simplicity, but your path is likely to be different, hence adjust set-Location in the above script.
Note 2: If these commands don't reveal the quest snap-Ins, you probably missed one of my pre-requisites. As I mentioned earlier, you must download and install the quest.activeroles.admanagement snap-In from Quest's site, and you need access to an active directory domain.
If you substitute the verb 'get' for 'add', then PSSnapin will display all registered snap-Ins including the Microsoft default sets.
# Optional instruction to display all PowerShell Snap-Ins
PowerShell 1.0 November 2008
PowerShell 2.0 April 2010
Note 1: Did you get just the Microsoft snap-Ins? Or did you get a snap-In from quest?
Note 2: In PowerShell 2.0 I also added remoting, hence the WSMan snapin.
SolarWinds' Network Performance Monitor will help you discover what's happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
As we will see, the killer reason for mastering profile.ps1 is so that you can load PSSnapins. As a result of this procedure PowerShell will load extra cmdlets effortlessly each time it starts.
Once you achieve mastery in a particular area, any difficulties that you endured during the learning process seem to fade into the background. So it is with understanding Profile.ps1. Configuring this file is ridiculously easy once you have mastered it, but impenetrably difficult when you try and figure it out for the first time.
The secret of setting-up profile.ps1 is attention to spelling. In particular, the filename 'profile' must be singular, and the directory name must be precisely: 'WindowsPowerShell'.
Let me give you a few pointers with the text file profile.ps1. The file must be called precisely profile.ps1. The name profileS.psL would be doubly wrong because of the plural filename and 'L' instead of a 1 in the extension.
You must save profile.ps1 into a specific directory. Begin your
drill-down by navigating to the C:\Documents and
Settings folder. Next you need to know the Windows profile name for the user who is logged on, in
my case \guyt. The rest of the path is My Documents\WindowsPowerShell.
Pay close attention to the folder name: WindowsPowerShell. Here is my full path.
It is in the above WindowsPowerShell folder that I save profile.ps1.
There is a whole micro-Industry in creating clever instructions for profile.ps1, (just as there was tweaking the old DOS autoexec.bat). For our mission we will focus on just two instructions, setting the HOME directory and loading snap-Ins.
# Simple instruction for Profile.ps1 (Feel free to amend c:\)
I always like to build on success, thus I include the simple command, 'set-Location c:\' merely to show that PowerShell is in fact reading profile.ps1. If this works and PowerShell opens at the c:\ prompt, then you could try a more realistic 'home' directory for your PowerShell, for example, set-Location c:\PowerShell (Providing you have a folder called precisely, PowerShell).
Summary of PowerShell's Add-PSSnapin
If you need to employ PowerShell to manipulate active directory, then seek additional cmdlets. The best the best sources are Quest and PowerGUI. Additionally, if you need to control PowerShell's start-up environment, then take the time to create and configure profile.ps1.
Once you have installed the snap-Ins, you need a command to load them each time PowerShell launches, that command is : add-PSSnapin. Why not get the best of both worlds? Master profile.ps1 and make sure that the quest.activeroles.admanagement snap-In is always available.
If you like this page then please share it with your friends
See more PowerShell QAD Scripts
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.