Sunday, 21 February 2016

PowerShell Command

Activate site collection feature

$site = Get-SPSite http://sp2010
 Enable-SPFeature -Identity “FeatureName” -Url $site.Url
 $site.Dispose()





Activate site collection features for all site collections in a Web Application 

$webApp = Get-SPWebApplication -Identity http://sp2010
 $webApp | Get-SPSite -limit all | ForEach-Object {Enable-SPFeature -Identity “FeatureName” -Url $_.Url}



Activate site feature 

$web = Get-SPWeb http://sp2010
 Enable-SPFeature -Identity “FeatureName” -Url $web.Url
 $web.Dispose()



Backup of site

Backup-SPSite -Identity "http://myspsite" -Path "C:\backups\myspsite.bak" -Force -Confirm:$False


Restore of site 

Restore-SPSite "http://myspsite:81" -Path C:\backups\myspsite-81.bak -Force -Confirm:$False



backup-spsite
identity http://server:site/
path c:\folder\filename.bak


export-spweb
identity http://server/site
path c:\folder\filename.cmp


import-spweb
identity http://server/restoresite
path c:\folder\filename.cmp

restore-spsite
identity http://server:site/
path c:\folder\filename.bak


Set Custom Message  for Access Denied

Set-SPCustomLayoutsPage -Identity AccessDenied 
-RelativePath "/_layouts/1033/Custom_Page.html" 
-WebApplication "http://indel3003:8004/"


Get SPLog Using PowerShell

Get-SPLogevent -starttime (get-date).addminutes(-20) | where-object {$_.correlation -eq "bd76559d-84a4-d0d9-a606-c30fe16cad3c"} | fl message > c:\users\userName\desktop\errors.txt



Change Database Instance 

$db = get-spdatabase -identity 04d5b4bc-5341-4388-a870-7922a01928fe
$db.ChangeDatabaseInstance(“<YourNewServer\InstanceNameHere”)
$db.Update()

Write-Host $db.DatabaseConnectionString


No comments:

Post a Comment