Useful PowerShell Commands

1) Command to get PowerShell Version: $PSVersionTable.PSVersion 2) Command to get the current directory of the PowerShell Script: a)  In PowerShell 3.0 $PSScriptRoot b) In PowerShell 2.0 $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition 3) Read xml file into PowerShell $xmlFilePath = “C:\SampleXmlFile.xml” [xml]$xmlFileContents = Get-Content $xmlFilePath

Continue reading

Handling session error on multiple frontend servers in ASP.NET 4.0

Perform the following steps to handle Session for Multiple Front End Servers 1) Add the tag under tag in the web.config file of all the front end servers For Example: <sessionState mode=”StateServer” timeout=”20″ stateConnectionString=”tcpip=server:port” /> Refer the following link for more information: http://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.100).aspx 2) Add the tag under tag in…

Continue reading

Backup Deployed WSP in SharePoint 2010

To take the backup of the WSP in SharePoint 2010, Run the following commands from PowerShell where SharePoint 2010 is configured. Add-PSSnapin Microsoft.SharePoint.PowerShell$farm = Get-SPFarm$file = $farm.Solutions.Item(“mysolution.wsp”).SolutionFile$file.SaveAs(“C:\WSPs\mysolution.wsp”) This saves the wsp to the desired location. The WSP can then be deployed like any other solution.

Continue reading