0

Introduction to PowerShell for SharePoint 2013 -2 (Administration)


<#
.SYNOPSIS
--------------------------------------------------------------------------------
Code generated by: Susheel Dakoju., Windows Powershell Host v 3.0
Generated on: 04-11-2015 19:28
Generated by:
Organization:
--------------------------------------------------------------------------------
.DESCRIPTION
- This script is generated for Capital Area .NET SharePoint Special Interest Group Meetup demonstration of basic Powershell commands for SharePoint
- This script is running against SharePoint 2013 powered by Powershell version 3.0
- Run as administrator to run the script sucessfully.
- This script is not for production use. The commenting and Intending is done to suite for quick demonstration and may not be adopted for organizational use
--------------------------------------------------------------------------------
#>
#---------------------------------------------------------------------#
#1. Create a new SiteCollection
#Prequsites/Assumption: A ready made webapplication with no root sitecollection created via GUI or Powershell
#---------------------------------------------------------------------#
New-SPSite -OwnerAlias SDsdakoju -Url http://contoso.com:4234/ -Name "CAPAREA SharePoint Demo 1" -Template STS#1

#---------------------------------------------------------------------#
#2. Create multiple new SiteCollection
#Prequsites/Assumption: A ready made webapplication along with root site sitecollection created via GUI or Powershell
#---------------------------------------------------------------------#
#-----------------------
#Create a new managed path
#-----------------------
New-SPManagedPath –RelativeURL "demo1" -WebApplication "http://contoso.com:4234/"
#-----------------------
#Create a new multiple sites
#-----------------------
New-SPSite -OwnerAlias SDsdakoju -Url http://contoso.com:4234/demo1/test -Name "CAPAREA SharePoint Demo 1" -Template STS#1 #already created
New-SPSite -OwnerAlias SDsdakoju -Url http://contoso.com:4234/demo1/test1 -Name "CAPAREA SharePoint Demo 1" -Template STS#1 #already created
New-SPSite -OwnerAlias SDsdakoju -Url http://contoso.com:4234/demo1/test2 -Name "CAPAREA SharePoint Demo 1" -Template STS#1 #already created
New-SPSite -OwnerAlias SDsdakoju -Url http://contoso.com:4234/demo1/test3 -Name "CAPAREA SharePoint Demo 1" -Template STS#0 #already created

#---------------------------------------------------------------------#
#3.Remove/Delete SiteCollection
#---------------------------------------------------------------------#
Remove-SPSite -Identity http://contoso.com:4234/demo1/test2 -Confirm

#Check if deleted
Get-SPSite -WebApplication http://contoso.com:4234/
#---------------------------------------------------------------------#
#3.Export a site
#All the operation in this section can be done even with UI under Back up and Restore section in CA
#---------------------------------------------------------------------#
Export-SPWeb -Identity http://contoso.com:4234/demo1/test3 -Path demo1_test3.cmp

#---------------------------------------------------------------------#
#4.Import a site
#All the operation in this section can be done even with UI under Back up and Restore section in CA
#---------------------------------------------------------------------#
Import-SPWeb -Identity http://contoso.com:1234/ -Path demo1_test3.cmp -Confirm -Force
#---------------------------------------------------------------------#
#5.Export a List or Library
# This is similar to Exporting a whole SPWEB but if Item URL is specified it exports only that.
#---------------------------------------------------------------------#
Export-SPWeb -Identity http://contoso.com:4234/demo1/test3/ -Path demo1_test3_doc1.cmp -ItemUrl "/demo1/test3/Shared Documents"

#---------------------------------------------------------------------#
#6.Import a List or Library
# This is similar to Importing a whole SPWEB, since Item URL is specified in export, import will get list only.
#---------------------------------------------------------------------#
Import-SPWeb -Identity http://contoso.com:1234/capareademo1/ -Path demo1_test3_doc1.cmp -Confirm -Force

Leave a Reply