<#
.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
--------------------------------------------------------------------------------
#>
#---------------------------------------------------------------------------------------#
# Getting Started
#---------------------------------------------------------------------------------------#
#---------------------------------------------------------------------#
#1. Get Current Powershell Version
#---------------------------------------------------------------------#
$PSVersionTable.PSVersion
#---------------------------------------------------------------------#
#2. Get count of Commands with 'SP' in the name SharePoint Snap-In
#---------------------------------------------------------------------#
Get-Help *sp* | Measure-Object
#---------------------------------------------------------------------#
#3. Get count of Commands with 'SP' in the name BEFORE ADDING SharePoint Snap-In
#---------------------------------------------------------------------#
Add-PSSnapin -Name Microsoft.SharePoint.Powershell
Get-Help *sp* | Measure-Object
#---------------------------------------------------------------------#
#4. Get count of Cmdlets with 'sp' in the name AFTER ADDING SharePoint Snap-In
#---------------------------------------------------------------------#
Get-Command *sp* | Where {$_.CommandType -match "cmdlet" }| Measure-Object
Get-Help *sp* | Measure-Object
#---------------------------------------------------------------------#
#5. Get count of Applications with 'sp' in the name AFTER ADDING SharePoint Snap-In
#---------------------------------------------------------------------#
Get-Command *sp* | Where {$_.CommandType -match "Application" }| Measure-Object
Get-Help *sp* | Measure-Object
#---------------------------------------------------------------------#
#6. Get count of Applications with 'sp' in the name AFTER ADDING SharePoint Snap-In
#---------------------------------------------------------------------#
Get-Command *sp* | Where {$_.CommandType -Match "cmdlet" -and $_.ModuleName -Match "Microsoft.SharePoint.PowerShell" }| Measure-Object
Get-Help *sp* | Measure-Object
#---------------------------------------------------------------------------------------#
# Developer: The folloowing script block creats and add content to SharePoint 2013 Sites
#---------------------------------------------------------------------------------------#
#---------------------------------------------------------------------#
#1. Get all available Web Templates
#---------------------------------------------------------------------#
Get-SPWebTemplate
#---------------------------------------------------------------------#
#2. Get availablet Web Templates which are team site or black site
#---------------------------------------------------------------------#
Get-SPWebTemplate | Where {$_.Title -match "Team Site" -or $_.Title -match "Blank Site"}
#---------------------------------------------------------------------#
#3. Demo: Insert Command from Show-Command window
#---------------------------------------------------------------------#
Show-Command
#New-SPWeb -Url http://conteso.com:1234/capareademo1/Caparea_1 -AddToTopNav -Name Caparea_1 -Template STS#1 -UseParentTopNav
#New-SPWeb -Url http://conteso.com:1234/capareademo1/Caparea_2 -AddToTopNav -Name Caparea_2 -Template STS#1 -UseParentTopNav
#----------------------**** Important *****---------------------------#
#4. The Start-SPAssignment cmdlet properly disposes of objects used with variable assignments
# 'Global' Parameter- All objects are assigned to the lifetime of the script
# Read more at : https://technet.microsoft.com/en-us/library/ff607664.aspx
#---------------------------------------------------------------------#
Start-SPAssignment -Global
#---------------------------------------------------------------------#
#5. Create two SharePoint List of Type Tasks and Document Library.
#---------------------------------------------------------------------#
$web = Get-SPWeb -Identity http://conteso:1234/capareademo1/Caparea_1
$web.Lists.Add("Project Tasks", "Holds Project Tasks","Tasks")
$web.Lists.Add("Project Documents", "Holds Project Documents","DocumentLibrary")
#---------------------------------------------------------------------#
#6. Updating SharePoint Content
#---------------------------------------------------------------------#
$lst = $web.Lists["Project Tasks"]
$lst.Title = "Project Tasks 1"
$lst.Update()
#forget update
#---------------------------------------------------------------------#
#7. Remove SharePoint Content
#---------------------------------------------------------------------#
Remove-SPWeb -Identity http://conteso.com:1234/capareademo1/Caparea_1 -Confirm
Remove-SPWeb -Identity http://conteso.com:1234/capareademo1/Caparea_2 -Confirm
#-------------------------**** Important *****------------------------#
#4. The Stop-SPAssignment cmdlet properly disposes of objects used with variable assignments
# 'Global' Parameter- Disposed of when the Stop-SPAssignment cmdlet is called
# Read more at : https://technet.microsoft.com/en-us/library/ff607664.aspx
#---------------------------------------------------------------------#
Stop-SPAssignment -Global
Like this:
Like Loading...
Related