Category: Powershell

Download all Site collection documents / Files using Powershell in specific folder

I have updated the script written by “Nico Martens” in below blog post

http://sharepointrelated.com/2014/11/11/download-all-content-in-a-site-collection/

Below script will download all your documents in specific folder of Site and List

Save this script as Get-SPContent.ps1 and run using below line

.\Get-SPContent.ps1 -SiteCollection "" -Destination ""

Continue reading “Download all Site collection documents / Files using Powershell in specific folder”

Advertisements

Upload files and sub folder to SharePoint library from local folder using PowerShell

#Replicate Local folder with subfolder and files in SharePoint document library
#=============================================================
#Prerequisite
#Document Library for uploading files should be already created
#=============================================================
#Author : Satish R Gadekar
#Date   : 11/13/2014
#=============================================================

Continue reading “Upload files and sub folder to SharePoint library from local folder using PowerShell”

Warm Up Script for SharePoint

You can use this warm up script after deployment in SharePoint it will bring back your site faster thna browser.

Write below line in text file and save as BAT file

####################################################################
powershell -command “& ‘D:\Satish\WarmUp\Satish\WarmUp.ps1′”
####################################################################

Write Below lines in text file and save as ps1 file

####################################################################
    $ver = $host | select version
    if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = “ReuseThread”} 
    if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null) {
        Add-PSSnapin “Microsoft.SharePoint.PowerShell”
    }
    
   function Get-WebPage([string]$url)
   {
       $wc = new-object net.webclient;
       $wc.credentials = [System.Net.CredentialCache]::DefaultCredentials;
      $pageContents = $wc.DownloadString($url);
      $wc.Dispose();
     return $pageContents;
   }
   

write-host “http://igtehydzbnv02:2210/sites/AppCentralSatish/“;
$html = Get-WebPage -url “http://igtehydzbnv02:2210/sites/AppCentralSatish/“;
write-host “Done”;
read-host;
#######################################################################

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.(SharePoint 2010 Powershell error)

Error:- “The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered when trying to run SharePoint 2010 PowerShell”

This message would also show up if you try to run the SharePoint 2010 Managment Shell without the proper permissions, or if the account does not have the proper permissions in SQL

OR





the SharePoint 2010 Management Shell was pointing to the incorrect version or path that is invalid and not compatible.

 To Verify which version is being used
1.  Bring up SharePoint 2010 Managment Shell (ignore) the error Message
2.  Type:
$ver=$host | select version
$ver.Version
3.  If you receive something like below.  If the Major version is not on 2, then you will get this runtime error.
Major  Minor  Build  Revision
—–  —–  —–  ——–
3      0      -1     -1
4.  Close out of SharePoint 2010 Managment Shell.
5.  Go back to the SharePoint 2010 Managment Shell Shortcut, right click and select “Properties”
6.  Under the Shortcut tab, Target: section, insert ”-version 2″ into the path, like so.  Make sure its before the -NoExit.
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe –version 2 -NoExit ” & ‘ C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ‘ “
7.  Click apply, and then Ok
8.  Reopen up the SharePoint 2010 Managment Shell with admin rights, and you should now no longer receive that error, you should then be able to run your scripts.

Enable/Disable Developer Dashboard Powershell command SharePoint 2010

Type below commands in Powershell

$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
$addsetting.Update()

Make it OnDemand

$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
$addsetting.Update()

Turn Off

$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
$addsetting.Update()