SharePoint Online: Working With List Settings Using PowerShell

In this article we will discuss the configuration of some of the important List Settings for SharePoint Online Lists. Though I have taken only a handful of operations to showcase in this demo, but remember there are lot more to explore.

Operation: How to enable “New Folder” Menu Command

We can see this setting available under “Advanced Settings” for the list as shown below-

1

We can play with this setting using PowerShell as described below-

2

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “EnableFolderCreation” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

3

Once this script executes successfully we can see list setting updated by navigating “Advanced Settings” of the list as shown below-

4

Operation: How to disable “List Item Attachments” Option

We can see this setting available under “Advanced Settings” for the list as shown below-

5

We can play with this setting using PowerShell as described below-

6

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “EnableAttachments” to False

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

7

Once this script executes successfully we can see list setting updated by navigating “Advanced Settings” of the list as shown below-

8

Operation: How to enable “Quick Launch” Option for List

We can see this setting available under “General Settings” for the list as shown below-

9

We can play with this setting using PowerShell as described below-

10

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “OnQuickLaunch” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

11

Once this script executes successfully we can see list setting updated by navigating “General Settings” of the list as shown below-

12

Operation: How to enable “Version History” for List Item Attachments

We can see this setting available under “Versioning Settings” for the list as shown below-

13

We can play with this setting using PowerShell as described below-

14

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “EnableVersioning” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

15

Once this script executes successfully we can see list setting updated by navigating “Versioning Settings” of the list as shown below-

16

We may work on additional version settings as well as shown below-

17

For example let try to enable Minor Versions for a document library “ProductDesigns” by using PowerShell

18

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “EnableMinorVersions” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

19

Once this script executes successfully we can see list setting updated by navigating “Versioning Settings” of the list as shown below-

20

Operation: How to enable “Require Check Out” Option

We can see this setting available under “Versioning Settings” for the list as shown below-

21

We can play with this setting using PowerShell as described below-

22

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “ForceCheckOut” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

23

Once this script executes successfully we can see list setting updated by navigating “Versioning Settings” of the list as shown below-

24

Operation: How to enable “Require Content Approval” Option

We can see this setting available under “Versioning Settings” for the list as shown below-

25

We can play with this setting using PowerShell as described below-

26

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “EnableModeration” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

27

Once this script executes successfully we can see list setting updated by navigating “Versioning Settings” of the list as shown below-

28

Operation: How to configure “Draft Item Security” Option

We can see this setting available under “Versioning Settings” for the list as shown below-

29

We can play with this setting using PowerShell as described below-

30

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “DraftVersionVisibility” to “Approver”. This setting will limit access to the draft items for the Approvers only.

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

31

Once this script executes successfully we can see list setting updated by navigating “Versioning Settings” of the list as shown below-

32

That is all for this demo.

Hope you find it helpful.

Advertisements

SharePoint Migration – Large List Details

This is article is next in the series of articles on “SharePoint Migration & Planning” Strategies. You can reach out to the previous articles in this series using the following links:

SharePoint Migration: Planning & Guidance On SharePoint Objects
SharePoint Migration – Export IIS Settings
SharePoint Migration – Export Alternate Access Mapping
SharePoint Migration – Export Content Database Details

In this article we will look for the PowerShell Scripts to export “SharePoint Large Lists” Report from source SharePoint Farm. This information will be helpful to track all the lists which contains more than “2000” items in it and provisioned in SharePoint Farm.

In Step 1 we will add the PowerShell Snapin to PowerShell Script as usual.

1

In Step 2 we define a function and initiate the export CSV file with Column Headers. For this demo I am exporting a few important properties like “WebApp Name, WebApp Url, Site Collection Url, Site Name, Site URL, List Name, List Item Count” but you may query all possible properties as you deemed fit

In Step 3 we execute the “Get-SPWebApplication” cmdlet to query the “Sites” & “Webs” Properties

In Step 4 we loop through the Sites Collection for a specific Web Application

In Step 5 we loop through the Webs Collection for a specific Site

In Step 6 we loop through the Lists Collection for a specific Web

In Step 7 we will filter all those lists which are having over “2000” items in them

In Step 8 we add the content of properties for each of the list to the CSV file

Always remember to dispose SharePoint Site & Web objects to avoid memory leaks. In Step 9 we will call the “dispose()” method

2

In Step 10 we will initialize path variables for export file & web applications. You can further extend this step by adding little bit of more automation flavor to make it more dynamic by reading parameters from input settings file

3

Once this script get executed successfully, it will export the Large List Details in a CSV File as shown below in Step 11

4

We can see the exported details as shown below in Step 12

5

Code Reference:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"Add-PSSnapin "Microsoft.SharePoint.PowerShell"
function Get-Large-List-Report(){ Try {        if (Test-Path $settingsFilePath)        {            Remove-Item $settingsFilePath        }
        Add-Content $settingsFilePath "WebApp Name,WebApp Url,Site Collection Url,Site Name,Site URL,List Name,List Item Count"
        $spWebApplication = Get-SPWebapplication $webApplicationUrl
        foreach($spSite in $spWebApplication.sites)        {            foreach($spWeb in $spSite.AllWebs)            {                foreach($spList in $spWeb.Lists)                {                    if($spList.ItemCount -gt 2000)                    {                        $content = $spWebApplication.Name + "," + $spWebApplication.Url + "," + $spSite.Url + "," + $spWeb.Title + "," + $spWeb.Url + "," + $spList.Title + "," +  $spList.ItemCount                        Add-content $settingsFilePath $content                    }                }                $spWeb.dispose()            }            $spSite.dispose()        }    }    Catch {         Write-Host $Error -ForegroundColor Yellow }}
Clear-Host
$settingsFilePath = "<CSV File Path>"$webApplicationUrl = "<Web Application Url>"
Get-Large-List-Report

That is all for this demo.

Hope you find it helpful.

SharePoint Migration – Export Content Database Details

This is article is next in the series of articles on “SharePoint Migration & Planning” Strategies. You can reach out to the previous articles in this series using the following links:

SharePoint Migration: Planning & Guidance On SharePoint Objects
SharePoint Migration – Export IIS Settings
SharePoint Migration – Export Alternate Access Mapping

In this article we will look for the PowerShell Scripts to export “SharePoint Content Databases” details from source SharePoint Farm. This information will be helpful to track all the “Content Databases” provisioned in SharePoint Farm.

In Step 1 we will add the PowerShell Snapin to PowerShell Script as usual

1

In Step 2 we define a function and initiate the export CSV file with Column Headers. For this demo I am exporting a few important properties like “Id, Content Database Name, Web Application Name, Server Name, Current Site Count” but you may query all possible properties as you deemed fit

In Step 3 we execute the “Get-SPContentDatabase” cmdlet to query the required properties

In Step 4 we loop through the properties collection for all Content Databases and list out the queried properties for each database

In Step 5 we add the content of properties for each of the Content Database to the CSV file

2

In Step 6 we will set the settings file path and call the function to export the Content Database Details

3

Once this script get executed successfully, it will export the Content Database Details in a CSV File as shown below in Step 7

4

We can see the exported details as shown below in Step 8

5

Code Reference:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"Add-PSSnapin "Microsoft.SharePoint.PowerShell"
function Get-Content-Databases(){ Try {        if (Test-Path $settingsFilePath)        {            Remove-Item $settingsFilePath        }
        Add-Content $settingsFilePath "Id,Content Database Name,web Application Name,Server Name,Current Site Count"
        $contentDBSettings = Get-SPContentDatabase | Select Id,Name,webApplication,Server,CurrentSiteCount
        foreach ($contentDBSetting in $contentDBSettings)        {            $id = $contentDBSetting.Id            $name = $contentDBSetting.Name            $webApplication = $contentDBSetting.webApplication            $server = $contentDBSetting.Server            $currentSiteCount = $contentDBSetting.CurrentSiteCount
            $settings = "$id,$name,$webApplication,$server,$currentSiteCount"             Add-content $settingsFilePath $settings        }    }    Catch {         Write-Host $Error -ForegroundColor Yellow }}
Clear-Host
$settingsFilePath = "<CSV File Path>"
Get-Content-Databases

That is all for this demo.

Hope you find it helpful.

 

 

 

 

SHAREPOINT MIGRATION – EXPORT Alternate Access Mapping

This is article is next in the series of articles on “SharePoint Migration & Planning” Strategies. You can reach out to the previous articles in this series using the following links:

  1. SHAREPOINT MIGRATION: PLANNING & GUIDANCE ON SHAREPOINT OBJECTS
  2. SHAREPOINT MIGRATION – EXPORT IIS SETTINGS

In this article we will look for the PowerShell Scripts to export “Alternate Access Mapping (AAMs)” Settings from source SharePoint Farm. This information will be helpful to track all the “AAMs” defined in SharePoint Farm.

In Step 1 we will add the PowerShell Snapin to PowerShell Script as usual

1

In Step 2 we define a function and initiate the export CSV file with Column Headers. For this demo I am exporting a few important properties like “Incoming Url, Zone, Public Url” but you may query all possible properties as you deemed fit

In Step 3 we execute the “Get-SPAlternateURL” cmdlet to query the required properties

In Step 4 we loop through the properties collection for all AAM Mapping and list out the queried properties for each mapping

In Step 5 we add the content of properties for each of the AAM Mapping to the CSV file

2

In Step 6 we will set the settings file path and call the function to export the AAM Mappings

3

Once this script get executed successfully, it will export the AAM Mappings in a CSV File as shown below in Step 7

4

We can see the exported mappings as shown below in Step 8

5

Code Reference:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"Add-PSSnapin "Microsoft.SharePoint.PowerShell"
function Get-Alternate-Access-URLs(){ Try {        if (Test-Path $settingsFilePath)        {            Remove-Item $settingsFilePath        }
        Add-Content $settingsFilePath "Incoming Url, Zone, Public Url"
        $aamSettings = Get-SPAlternateURL | Select IncomingUrl,Zone,PublicUrl
        foreach ($aamSetting in $aamSettings)        {            $incomingUrl = $aamSetting.IncomingUrl            $zone = $aamSetting.Zone            $publicUrl = $aamSetting.PublicUrl
            $settings = "$incomingUrl, $zone, $publicUrl"             Add-content $settingsFilePath $settings        }    }    Catch {         Write-Host $Error -ForegroundColor Yellow }}
Clear-Host
$settingsFilePath = "C:\Prashant\PowerShell\SharePoint Migration\PowerShell - Get-Alternate-Access-URLs\Alternate-Access-Urls.csv"
Get-Alternate-Access-URLs

That is all for this demo.

Hope you find it helpful.

SharePoint Migration – Export IIS Settings

This is article is next in the series of articles on “SharePoint Migration & Planning” Strategies. You can reach out to the previous articles in this series using the following links:

SharePoint Migration: Planning & Guidance On SharePoint Objects

In this article we will look for the PowerShell Scripts to export IIS Settings from source SharePoint Farm. This information will be helpful to track all the “Application Pool” accounts used to configure Web Applications in the Farm.

There could be more properties that you can export but for this demo I am considering following important properties:

Site Name, Site Path, Application Pool, Bindings, Identity, Password

In Step 1 we will import module “WebAdministration” which gives us the methods to work with “IIS Manager” Objects

1

In Step 2 we will retrieve items from IIS directory using wildcard path search “IIS:\Sites\*”

In Step 3 we will enlist the header of the output Settings file by using the name of properties that we are pulling from IIS

In Step 4 we will fetch properties “Site Name, Site Path, Application Pool, Bindings, Identity, Password” for each IIS Site

In Step 5 we will append the properties to the output file for each of the IIS sites we have in Farm

2

In Step 6 we are specifying the path for output file which would be in the form of CSV

In Step 7 we are calling the function executing Step 1-6

3

Once the script executed successfully it will generate the output file as shown below-

4

And here is the data that was added to the output file during the execution of the above script

We can see IIS details for each Site (Web Application) added to the SharePoint Farm and this information is really crucial to document during the Migration planning phase.

5

Code Reference:

Import-Module WebAdministration
function Get-IIS-Settings(){    param($ListName,$ScriptPath,$FileDateTimeStamp) Try {        if (Test-Path $settingsFilePath)        {            Remove-Item $settingsFilePath        }
        $iisSites = Get-Item IIS:\Sites\*
        Add-Content $settingsFilePath "Site Name , Site Path , Application Pool , Bindings , Identity , Password"
        foreach ($iisSite in $iisSites)        {            $appPoolName = $iisSite.ApplicationPool            $appPool = get-item "IIS:\AppPools\$appPoolName"            $processModel = $appPool.processModel            $appPoolIdentity = $processModel.username            $appPoolIdentityPassword = $processModel.password            $iisBindings = $iisSite.Bindings            $iisBindingCollection = $iisBindings.Collection             $siteName = $iisSite.Name            $sitePath = $iisSite.physicalPath
            $settings = "$siteName, $sitePath, $appPoolName,$iisBindingCollection,$appPoolIdentity, $appPoolIdentityPassword"             Add-content $settingsFilePath $settings        }
    }    Catch {         Write-Host $Error -ForegroundColor Yellow }}
Clear-Host
$settingsFilePath = "C:\Prashant\PowerShell\SharePoint Migration\IISSettings.csv"
Get-IIS-Settings

Hope you find it helpful.

SharePoint Migration: Planning & Guidance on SharePoint Objects

1

While performing SharePoint Migration we need to do lot of planning before actually starting even with the basic step on migration.

Planning includes well defined list of SharePoint Artifacts, Settings, or Configurations that must be identified beforehand and accordingly migration strategy can be worked out.

SharePoint Migration involves the following stages:

  • Inventory Audits
  • Configuration Migration
  • Schema Migration
  • Data Migration
  • Validation

In this article I will explain you detailed list of SharePoint Inventory that must be pulled out and kept stored as backup safely atleast during the migration phase.

 SharePoint Inventory Map

Below is the small Inventory Map for SharePoint Objects & Artifacts that we should always consider during the Planning Phase for SharePoint Migration.

In the upcoming sections of this article we discuss each of the Object/Artifact in more details from data collection stand point.

2

SharePoint Objects & Properties

Here is list of objects that should be queried during the initiation phase of migration.

SharePoint Farm

We should query SharePoint Farm Object to get it Properties, Configurations settings, Level of SharePoint Logging and Server details which are associated to this farm

 

3

Configuration & Settings

We should query SharePoint to get configuration settings for IIS, SharePoint Designer, Alternate Access and Common Web Service (SPServiceHostConfig)

4

Databases

We should query SharePoint to get details on databases designated as Content & Configuration databases associated with current Farm

5

Web Application, Sites, (Site Map)

We should query SharePoint to get details on Web Applications, Site Collections, Sites Subsites (Site Map), Site Templates especially the custom templates if you want to have sites based on these custom templates at destination too

6

Lists & Libraries

We should query SharePoint to get details on List Schema, Item Count, List Permissions, Item Specific Permissions if any and also report of large lists. This information will very helpful while migrating Schema & data at later stage of Migration process

7

Accounts, Authentication & Claim Providers

We should query SharePoint to get details on Managed Accounts, Application Pool Accounts, Authentication Providers and Installed Certificates Information.

8

Custom Solutions

We should query SharePoint to get details on custom WebParts, Features, Time Jobs, Layout Pages and other solutions (WSPs). This information is really important to migrate or rewrite functionalities as deemed fit. We also need to gather source code for each of the custom solutions as it might be required during migration issues encountered during/after migration.

9

Service Applications

We should query SharePoint to get details on Service Applications, Application Instances, Load Balancer Configuration. Information on Server Applications is important to help understand and troubleshoot issues during/after migration

10

Business Connectivity Service Applications

We should query SharePoint to get details on configuration settings for BCS data connection files. This will be really important to know all connection details for LOBs connected using BCS.

11

Search Service Applications

Search is one of the most complex Service applications when it comes to migration. So it really important that we should detailed out each granular piece of information associated with Search service applications.

We should query SharePoint to get details on configuration settings for Search Service Applications, Query Keywords, Query Scope, Query Rules, Query Suggestion, Ranking Model, Security Trimmer, and Application Proxies.

12

Application Specific Properties & Settings for Service Applications

Most Service applications expose a set of properties specific to each of them. It is important detailed out all possible details on each of application specific properties that we can query from SharePoint as shown below

13

I will keep on updating this article as I get more relevant information to include so that it could be proved as one stop reference for SharePoint Migration Guidance.

In the upcoming articles on SharePoint Migration I will show you implementation details on how to gather the inventory for each of the above mention objects.

So stay tuned.

Hope you find it helpful.

SharePoint Online: Working With List Content Types Using PowerShell

In this article we will discuss the configuration of some of the important operations on Content Type for SharePoint Online Lists. Though I have taken only a handful of operations to showcase in this demo, but remember there are lot more to explore.

Operation: How to enable “Content Types” for List

We can see this setting available under “Advanced Settings” for the list as shown below-

1

We can play with this setting using PowerShell as described below-

2

In Step 1 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 2 we will set “ContentTypesEnabled” to True

In Step 3 we will update the list property by calling “Update” method

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

3

Once this script executes successfully we can see list setting updated by navigating “Advanced Settings” of the list as shown below-

4

Operation: How to “Add Existing Content Type To List”

We can see this setting available under “List Settings” for the list as shown below-

5

We can play with this setting using PowerShell as described below-

6

In Step 1 we will get the object reference to the respective Web

In Step 2 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 3 we will get the object reference to the respective list by calling “GetById” method on Content Types collection

In Step 4 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 5 we will display success message to the Users if Step 4 executes successfully

In Step 6 we will call function that we have explained in Step 1-5

7

Once this script executes successfully we can see a new content type added by navigating “List Settings” of the list as shown below-

We can notice the new content type added to the List Content Types Collection

8

Operation: How to “Get List of All Content Types”

We can see this setting available under “List Settings” for the list as shown below-

9

We can play with this setting using PowerShell as described below-

10

In Step 1 we will get the object reference to the respective Web in context of which this code is executing

In Step 2 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 3 we will get List Content Types Collection

In Step 4 we call the “Load” function to retrieve List Content Types Collection properties from server

In Step 5 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 6 & 7 we will loop through the Content Types Collection and display relevant properties (ex. Name, ID and so on) from the collection

In Step 8 we will call function that we have explained in Step 1-7

11

Once this script executes successfully we can see list of content types by navigating “List Settings” of the list as shown below-

12

Operation: How to “Delete Existing Content Types” From List

We can see the List of Content Types already added to List under “List Settings” as shown below-

12

We can delete any Content Type from list by using PowerShell by using PowerShell as described below-

13

In Step 1 we will get the object reference to the respective Web in context of which this code is executing

In Step 2 we will get the object reference to the respective list by calling “GetByTitle” method

In Step 3 we will get List Content Types Collection

In Step 4 we call the “Load” function to retrieve List Content Types Collection properties from server

In Step 5 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 6 we will loop through the Content Types Collection

In Step 7 we will look for required content types that are intended to delete. In this example we will compare the Content Type Name to ensure that only intended content type are deleted

In Step 8 we will call “DeleteObject” method to delete the respective content type from Content Types Collection of List

In Step 9 we will send the batch request to SharePoint Server for processing by calling “ExecuteQuery” method

In Step 10 we will display success message after Step 9 got executed successfully

In Step 11 we will call function that we have explained in Step 1-10

14

Once this script is executed successfully the respective content type will be deleted from Content Types List and this can we verified from the UI by navigating through “List Settings”

15

That is all for this demo.

Hope you find it helpful.