Write Power Shell Script to Lock and Unloock a Site in SharePoint 2010

Below Power Shell Script will Unlock a SharePoint site if it is in locked/read-only.#Region variable declarationWrite-Host “UnLock status started…..”Add-PSSnapin Microsoft.Sharepoint.PowershellSet-SPSite -Identity “<site-url>” -LockState “Unlock”Write-Host “Task completed…..”Read-Host -Prompt “The above error occurred. Press Enter to exit.”For -LockState attribute there are mainly 4 parameters that can be used:Unlock – To unlock site collection and make it available to … Read more

PowerShell Command List used in SharePoint 2010

PowerShell Command which are common in use for a SharePoint Developer.   BackupBackup-SPSite http://oldsite -Path C:backupsitename.bak RestoreRestore-SPSite http://newsite -Path C:backupsitename.bak Add WSPAdd-SPsolution “C:File1.wsp” Update WSPUpdate-SpSolution -Identity File1.wsp -LiteralPath “C:File1.wsp” -GACDeployment Install WSPInstall-SPSolution -Identity “File.wsp”  -WebApplication “http://siteurl” EnableFeatureEnable-SPFeature -identity “MyFeature” -URL “http://siteurl” Disable FeatureDisable-SPFeature -identity “MyFeature” -URL “http://siteurl” InstallFeatureInstall-SPFeature -path “MySPFeature1” Uninstall FeatureUninstall-SPFeature -Identity “MySPFeature1” Get … Read more

Powershell Command to add a file to root of SharePoint

This blog will explain about adding a file to SharePoint root.Generally sharepoint structure is http://server/pages/page1.htmlSuppose you need to add a file in root which should access by http://server/page1.html This can be done by powershell command. Write-Host “Powershell started…..”Add-PSSnapIn Microsoft.SharePoint.PowerShell$fileBytes = [system.io.file]::ReadAllBytes(“C:myfolderpage1.html”);$site = Get-SPSite “http://server”;$site.RootWeb.Files.Add(“page1.html“, $fileBytes, $true);Write-Host “Done…”