Install the snapin:
Install.bat
@SET GACUTIL="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe"
@SET INSTALLUTIL="C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe"
%GACUTIL% -if %~dp0anavijai.SP2010.PowerShell.dll
%INSTALLUTIL% %~dp0anavijai.SP2010.PowerShell.dll
Pause
Register the snapin:
Add-PSSnapin anavijai.SP2010.PowerShell
Get-Command – Module anavijai.SP2010.PowerShell
If you register the custom powershell cmdlet using the Add-PSSnapin command the snapin will be available only for that session. Each and every time you go for a new session you will need to register the snapin using Add-PSSnapin. You can register the custom powershell cmdlet in another way by creating an xml file and deploying the file in "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration". So that you do not need to register the cmdlet each and every time.
Create an xml file:
anavijaiSP2010Cmdlet.xml
|
<ps:Config xmlns:ps="urn:Microsoft.SharePoint.PowerShell" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:Microsoft.SharePoint.PowerShell SPCmdletSchema.xsd"> <ps:Assembly Name="anavijai.SP2010.PowerShell, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bcaceceb1f6761bc"> <ps:Cmdlet> <ps:VerbName>Get-SPWebTitle</ps:VerbName> <ps:ClassName>anavijai.SP2010.PowerShell.GetSPWebTitle</ps:ClassName> <ps:HelpFile>anavijai.SP2010.PowerShell.dll-help.xml</ps:HelpFile> </ps:Cmdlet> </ps:Assembly> </ps:Config>
|
Deploy the file in the "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration".
You can include the same in the Installer.bat
xcopy %~dp0anavijaiSP2010Cmdlet.xml "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration"
Now we will be able to access the Get-SPWebTitle directly without using the Add-PSSnapin command.

Former memberPosted Apr 19, 2011, 12:02 AM
I was just reading your this post [It is far to be called as Article , so I used the noun Post] In 1st line you have mentioned something about "cmdlet " . As a reader , I would love to see more on first "What is cmdlet " Then you mentioned something about "snpain" . again as a reader , I would love to see more on first "What is snpain" or atleast some link to refer where I can read more about these. Then you are writing some bat file. How to write ? on notepad or on some other stuff is missing there . I like your energy on writing so suggesting you , please donot be miser at words. Only quantity does not speak. and if you are aspired to be Microsoft MVP quality does matter far more than quanity. any way you call. and I hope you will repsond back this comment Thanks