Extract Documents to Folder based on Managed Metadata Column - SharePoint

Image
  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

Get Site Collection Administrators



For one activity I had to find all Site Collection Administrators for each and every web application. since I had only few web applications. I managed get it done with the help of bellow link.

 https://sharepoint.stackexchange.com/questions/209841/get-site-collection-administrators-using-powershell

after few modifications, now this script will generate a .csv file with site name and all site collection administrators for each site collection.

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

$webApp = Get-SPWebApplication -Identity "http://webappURL"

$logFilePath = "FilePath\$($webApp.Name)-Log.log";

Add-Content -Path $logFilePath -value "SiteName | Admin Name";

$siteCollections = $webApp.Sites ;

foreach($spSite in $siteCollections)
{

  $siteURL$spSite.Url;

  $siteCollectionAdmins = $spSite.RootWeb.SiteAdministrators;

    foreach ($admin in $siteCollectionAdmins)
    {

      Write-Host $spSite.Url "|" $admin.DisplayName;
      Add-Content -Path $logFilePath -value " $($siteURL) | $($admin.DisplayName)";

    }

  $spSite.Dispose();

}


Hope This will help someone.

Cheers

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