Showing posts with label Powershell Script. Show all posts
Showing posts with label Powershell Script. Show all posts

Saturday, February 13, 2016

Enable Save a publishing site collection as template and save site as template url in SharePoint 2013.

In this article , Enable save as template page
#Get site url 

$web = Get-SPWeb http://peakfinders/
$web.AllProperties["SaveSiteAsTemplateEnabled"] = "true"
$web.Update() 

 Now you can able  access the save site as template :


_layouts/savetmpl.aspx

How to unlock the SharePoint site while PowerShell command

Two ways to change:


UPDATE AllSites SET LifeCycleFlags = 1 WHERE ID = '(your site collection GUID)'
 
Open central adminstration-->management application-->Configure site quotas and lock
 

Friday, February 12, 2016

How to Finding Column Display and Internal Names in Custom list using Powershell

$web = Get-SPWeb http://peakfinders
$list = $web.Lists["Employee"]
$list.fields | select Title, InternalName, Hidden, CanBeDeleted | sort title | ft -AutoSize

As you will most often be interested in the non-hidden fields, you can add a Where to filter them:

$list.fields | select Title, InternalName, Hidden, Sealed, CanBeDeleted | where {$_.Hidden -eq $false} | sort title | ft –AutoSize

Friday, January 22, 2016

How to Upload files with ftp using powershell

# create the FtpWebRequest and configure it
$ftp = [System.Net.FtpWebRequest]::Create("ftp://peakfinder/logome.png")
$ftp = [System.Net.FtpWebRequest]$ftp
$ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$ftp.Credentials = new-object System.Net.NetworkCredential("peak","peak@123")
$ftp.UseBinary = $true
$ftp.UsePassive = $true
# read in the file to upload as a byte array
$content = [System.IO.File]::ReadAllBytes("C:\me.png")
$ftp.ContentLength = $content.Length
# get the request stream, and write the bytes into it
$rs = $ftp.GetRequestStream()
$rs.Write($content, 0, $content.Length)
# be sure to clean up after ourselves
$rs.Close()
$rs.Dispose()

Wednesday, January 20, 2016

How to moving Site Collection to a different Web Application

  1. update your user profile services for mysite host location, Create Managed Path, enable self services site creation,
  2. Now move all existing MySite collection from existing web app to new webApp.

Thursday, January 7, 2016

Difference between the timer job and windows task scheduler in SharePoint and How to use it?


Timer Jobs

Windows Task Scheduler

<![if !supportLists]>1.     <![endif]>Timer jobs require downtime to deploy.
<![if !supportLists]>2.     <![endif]>Control via Central Admin.
<![if !supportLists]>3.     <![endif]>Schedule of Timer Job will be backed up and restore in your normal process of SharePoint backup and restore.
<![if !supportLists]>4.     <![endif]>Can be deployed using standard WSP solution.
<![if !supportLists]>5.     <![endif]>Custom Timer Jobs provides the power to specify Job LockTypes (i.e. SPJobLockTypes) which guarantees that multiple instances of same job will never execute at the same point in time.

<![if !supportLists]>1.     <![endif]>Windows Scheduled task doesn't require downtime to install/update.
<![if !supportLists]>2.     <![endif]>The task will only run on the server that you've installed it on.
<![if !supportLists]>3.     <![endif]>Administrator needs to manually manage backup and restore of Schedule Tasks
<![if !supportLists]>4.     <![endif]>No standard built in deployment method
<![if !supportLists]>5.     <![endif]>No multiple instance guarantee. Administrator needs to make sure that no two instances are running at the same time.




 Single point of failure : Windows Task Scheduler need to be configured on all the web servers. If you configure to run the job on 1 server only, and this server crashes, job will not work at all.
Status Reporting : Windows Task Scheduler doesn't have any reporting on when was the last time job got executed and what was the status. Only option is logging. Whereas SharePoint have a UI to show status of all the jobs and their status.
Security : In case of Windows Task Scheduler, you will need go to IT Admins and request for a special username/password to run such jobs where as SharePoint Timer Jobs automatically run under SharePoint Timer Job account.
Deployment : There is no easy way to deploy Windows Task Scheduler tasks and application which need to executed in a FARM environment. This will require lot of manual steps by IT Admin. SharePoint jobs can be deployed using WSP's.










Wednesday, December 16, 2015

How to task Scheduler in SharePoint Power Shell Script


  • Create a notepad file
  • Save  that file .bat format
  • Include this code that .bat file


Powershell.exe -executionpolicy remotesigned -File  D:\TScripts\getfarmdetails.ps1



  • Create a notepad file 
  • Save  that file .ps1 format
Type 1:
Add-PSSnapin Microsoft.SharePoint.Powershell

(get-spfarm).buildversion

Type 2:
Add-PSSnapin Microsoft.SharePoint.Powershell
 Get-SPFarm | Select BuildVersion

Wednesday, December 9, 2015

Programmatically Create SharePoint Toplink bar and Quicklaunch bar in SharePoint 2010 and 2013

Programmatically Create TopLink Bar in SharePoint site collection:

SPNavigationNodeCollection topnav = oweb.Navigation.TopNavigationBar;
SPNavigationNode node = new SPNavigationNode("Title", "URL");
node = topnav.AddAsLast(node);
node.Update();


Similarly, To create Quicklaunch bar

SPNavigationNodeCollection topnav = oweb.Navigation.QuickLaunch;
SPNavigationNode node = new SPNavigationNode("Title", "URL");
node = topnav.AddAsLast(node);
node.Update();

PowerShell command to enable the Timerjob feature

Enable-SPFeature -Identity "FeatureName" -url "http://siteURL/"

Backup and Restore using Powershell Error: 0x80070003 At line:1 char:1

To resolve the below error:

<nativehr>0x80070003</nativehr><nativestack></nativestack>


Use this Command:
upgrade-spcontentdatabase 'Mycontentdatabasename'

Lock or unlock SharePoint site using PowerShell Command

Set-SPSite -Identity "<SiteCollection>" -LockState "<State>"

States:
Unlock
NoAdditions
ReadOnly
NoAccess

Thursday, November 12, 2015

How to custom action url in Sharepoint list using Powershell

In this post we have creating custom action url in testEmployee list
Please see the below script

Add-PSSnapin "Microsoft.Sharepoint.Powershell"
 $site = "https://sharepointqa/"
 $web = Get-SPWeb $site
 $list = $web.Lists["testEmployee"]
 $customAction = $list.UserCustomActions | Where-Object {$_.Title -eq "New Entry"}
 Write-Host $customAction -f "blue"
 $customAction.Url = "https://peakfinders.blogspot.com"
 $customAction.Update();

Wednesday, October 28, 2015

SharePoint randomly displays web part error or XSLTTransformTimeout Power shell Script

We have facing this issue unable to display webpart.

When we have create more than 120 columns in our list Its shows error in our page

Default setting is 1 second. The PowerShell code below changes it to 2 seconds which should be sufficient for your farm.  So,we will choosing 4 seconds timeout. 



Powershell Script:

$farm = Get-SPFarm
$farm.XSLTTransformTimeout = 4
$farm.Update()



Effects:

If you backup/restore a site collection, you get this error when displaying All Items views.
I created a view loading 20 items at a time instead of all and it fixed the issue.

Wednesday, August 5, 2015

Import and Export subsite in SharePoint 2013 Using PowerShell Script

 Add-PSSnapin Microsoft.SharePoint.PowerShell


 Export-SPWeb "http://raghu/sites/test/test1" –Path "C:\rm.cmp" -includeusersecurity

 Import-SPWeb "http://raghu/sites/test/test1" -path "C:\rm.cmp" -IncludeUserSecurity

Wednesday, May 27, 2015

How to activate the V2VPublishedLinks in SharePoint 2013?


Enable-SPFeature –identity V2VPublishedLinks -URL http://YourWebApp


Install-SPFeature V2VPublishedLinks

Wednesday, May 20, 2015

How to enable Save as template site in Site action Categories Site collection level using Powershell

$web = Get-SPWeb "http://spserver/sites/Raghu/"
$web.AllProperties["SaveSiteAsTemplateEnabled"] = "true"
$web.Update()

Tuesday, April 28, 2015

How to enable the developer dashboard in Sharepoint 2013 in Powershell

The following options for the Developer Dashboard:
On
SharePoint 2010: The Developer Dashboard will always be rendered at the bottom of each page
SharePoint 2013: The Developer Dashboard icon will always be displayed at the top right corner.
It will not be appended to each page. Off
SharePoint 2010 & 2013: The Developer Dashboard will not be available
OnDemand
SharePoint 2010: The Developer Dashboard will only be appended to
a page after clicking on the icon in the ribbon
SharePoint 2013: This mode is not available in 2013 since it reflects the behavior of On now

$svc = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$dds = $svc.DeveloperDashboardSettings
$dds.DisplayLevel = "On"
$dds.Update()

Thursday, April 9, 2015

Delete SharePoint groups in Powershell

In this article ,We can create SharePoint group in any environment.


 But, we can see sometimes group name is not available but group name exists in SharePoint database. 

Powershell:


$spWeb = Get-SPWeb "http://peakfinders.blogspot.in/"$spGroups = $spWeb.SiteGroups$groups = ("Emp-Directory","Employee")ForEach($group in $groups) {
$spGroups.Remove($group);
}$spWeb.Dispose()