Extract Documents to Folder based on Managed Metadata Column - SharePoint

  How to Extract documents from Multiple Document libraries in to Folders. Each has a Managed Metadata Column with Sub Terms. I have created three Functions to  Download Document Create Folder Main Method Addition to above, script will log the Document URL and destination Folder Path in .log file Create Folder   Function   Create-Folder {      param  ( $folderPath )      if  (!( Test-Path  -path  $folderPath ))     {          New-Item   $folderPath  -type directory     } } Download Document ( this is stolen from Stackoverflow 😁 ) Function   Download-Document {      param ( $web ,  $folderPath ,  $docItem )       #File Download Snippet Reffered From : https://stackoverflow.com/questions/43350575/how-to-use-powershell-to-download-files-from-sharepoint        $File  =  $web .GetFile ( $docItem .Url )          $Binary  =  $File .OpenBinary ()          $detinationPath  =  $folderPath  +  "\"  +  $File .Name ;          $Stream  =  New-Object  System.IO.FileStream( $detinationPath

Delete Sub sites Using PowerShell SharePoint 2013

Delete Sub sites Using PowerShell SharePoint 2013

Recently I had to delete 50plus sub sites from one of my site collection which was created through script specified here.

All my sites had a naming conversion with a number which helped me to select the site dynamically.

Add-PSSnapin Microsoft.SharePoint.PowerShell

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

$sequencestart =3000;
$maxNumber = 3100;
$deleteCount =0;

$siteURLPrefix = "http://get-spnote.com/subsite-";
for($i=$sequencestart ; $i -lt $maxNumber; $i++)
    $url = $siteURLPrefix+$i;
    Write-Host $url;

    #Gets the Sub site in to vairable, If Site is not existing Error Action parameter will not throw an exception
    $web = Get-SPWeb -Identity $url -ErrorAction SilentlyContinue;

            Write-Host "Site Exists..."
            Write-Host $url "is getting deleted" -f Yellow;
            Remove-SPWeb -Identity $url -Confirm:$false;
            Write-Host $url "dleted successfully.." -f Green;
            $deleteCount ++;

            Write-Host $url " Site Not Exists" -f Red ;

       $web ="";


Write-Host $deleteCount " Sites Deleted";

Hope This might help someone to save

Pre-Upgrade Check List

Download Our Free SharePoint Pre-Upgrade Check List

* indicates required

Vintage Clan

Popular posts from this blog

System.Data.SqlClient.SqlException (0x80131904): The EXECUTE permission - User Profile Issue

How to Create Host Header to SharePoint Web Application

SharePoint 2013 Access Denied in Site Collections in Web Application