Create SharePoint Site (SPWeb) using Custom Template and PowerShell

I got a task to setup company’s hierarchy using our own custom created site template. My first priority is to achieve this task through PowerShell. Creating site collection or sub site through PowerShell is fairly a simple task, the command for creating sub site is

New-SPWeb http://sharepoint/subweb1 -Template “STS#0”

Ref: http://technet.microsoft.com/en-us/library/ff607579(v=office.15).aspx

I tried to replace the template name with my custom template’s name which I found out through the below script:

Add-PSSnapin Microsoft.Sharepoint.Powershell
$web = get-spweb https://sharepoint
$template = $web.GetAvailableWebTemplates(1033) | Where-Object {$_.Title -eq “<Custom Templete Title>”}
Write-Host $template.Name

Create SharePoint Site (SPWeb) using Custom Template and PowerShell

In the below script substitute the default template name with my custom template name but this didn’t work

New-SPWeb -Url “https://sharepoint/newsubsite” -Template “{D839E38A-F9DF-4B35-BDA7-A1E273C51EAB}#XXXX Template”

 Output:

Create SharePoint Site (SPWeb) using Custom Template and PowerShell

After looking into documentation the parameter it takes as Template is SPWebTemplatePipeBind which is optional. If someone doesn’t set the template, the site will be created but the template isn’t applied which will then prompt for template selection against its first visit. Finally I came up with the below script which worked like a charm.

 Add-PSSnapin Microsoft.Sharepoint.Powershell
$web = get-spweb https://sharepoint
$template = $web.GetAvailableWebTemplates(1033) | Where-Object {$_.Title -eq “<Custom Templete Title>”}
$newweb = New-SPWeb -Url “https://sharepoint/newsubsite” 
$newweb.ApplyWebTemplate($template.Name)

Setting up a new production server by restoring the Content database

I had a requirement in which I had to build a new SharePoint server and migrate the current data to the new server. The current production server ran into many system level issue and the company who setup the server couldn’t be approached. After nailing down almost all the major issues which included lot of registry repairs and permission, FIM configuration, account setups and permissions, services configuration etc., the server was still facing issues and its behavior was intermittent which then finally claimed for the new server build J

After setting up the new server taking care of Microsoft best practices and recommendations it was time to migrate data!

Fair and simple approach:

  • Get the site collection backup from current production site
  • Restore it into new production having all the configuration same as old server

And this didn’t work :)

Setting up a new production server by restoring the Content database

I tried to resolve the issue but it was taking time and didn’t get any promising solution at first attempt so the second option was to move the content database from old server to new.

The old version was SharePoint Server Enterprise and new server setup was SharePoint Server Enterprise SP1

Steps followed on new server:

Step 1: Backup the content database from old server and restore it in new server

Step 2: Create a web application on specific port (don’t create site collection)

Step 3: go to Application Management-> Manage content databases

Setting up a new production server by restoring the Content database

Setting up a new production server by restoring the Content database

Remove the current content database by clicking on it and check the “Remove content database” and then add the content database and set the same name of the restored content DB.

Setting up a new production server by restoring the Content database

Now just hit the URL, it should be working!

Setting up a new production server by restoring the Content database

PS Command: Upgrade-SPContentDatabase <WSS_Content>

Upgrades the existing <WSS_Content> content database schema and then performs only build-to-build upgrade actions on existing site collections if required. This operation does not changed the CompatibilityLevel for existing site collections in this database.

Setting up a new production server by restoring the Content database

Setting up a new production server by restoring the Content database

The error is gone!

Free MCP Exam Vouchers for Microsoft Virtual Academy (MVA) profile holders

Microsoft Innovation Centre (MIC) Pakistan has taken a nice initiative of sharing free MCP Exam vouchers for Top Microsoft Virtual Academy (MVA) profile holders (from Pakistan). MVA offers free online Microsoft training delivered by experts to help technologists continually learn with hundreds of courses. On MVA you can not only take live sessions but also can watch recordings on latest Microsoft Products & Technologies. You can get IT Pro trainings through the courses offered by Microsoft Virtual Academy and prepare yourself for Microsoft certifications.

FREE MCP exam vouchers

FREE MCP exam vouchers

This initiative is not just to promote MVA in Pakistan but also encourages students and professional to take free online courses to get aware on new technologies and also improve their skill set which will be beneficial in their job and projects.

I am also an MVA profile holder and have taken many trainings, I also have recommended many of my colleagues and students to avail these opportunities as these are conducted by technology experts having years of experience. If you haven’t taken any training from Microsoft Virtual Academy then I highly recommend you to get benefit from it. For more updates please visit Microsoft Developer.

Below is list of courses which you can take through Microsoft Virtual Academy:
Azure

Hyper-V

Hybrid Cloud

System Center 2012

Windows Server 2012

Windows 8.1

Office 365

Misc


You are eligible to give below exams using free exam vouchers:

Important:
– The vouchers are only applicable if you schedule exam through Prometric.
– Awarded vouchers are valid till 31st December, 2014 only so schedule your exam prior the mentioned date.
– Awarded vouchers can only be redeemed against 70-*** exams.
– For queries relating how the voucher at Prometric can be utilized or any issues redeeming, please contact regional Prometric center.
– One voucher can only be redeemed against one exam
– The decision of jury to award voucher is Non-challengeable.

SharePoint 2013 Governance

Governance is the set of policies, roles, responsibilities, and processes that control how an organization’s business divisions and IT teams work together to achieve its goals. Every organization has unique needs and goals that influence its approach to governance. Below are the three major areas of SharePoint 2013 Governance:

  • IT Governance
  • information Management
  • Application Management

You can see below image which shows the What is Governance in SharePoint 2013, its three major areas and also shows key information about these areas.

What is governance in SharePoint 2013

What is governance in SharePoint 2013

You can learn more about SharePoint governance from this Technet article.

Free Exam vouchers for Windows Azure OR Office 365 exams

Microsoft has announced today on Born To Learn portal by Andrew Parsons for free exam vouchers for Windows Azure or Office 365 Certification exams. This offer is for limited time and will end 31st December, 2014.

Request a voucher and be among the first certified for windows Azure and office 365. Below is the exam details which you can avail using the free exam voucher.

  • 70-532 (beta): Developing Microsoft Azure Solutions
  • 70-533: Implementing Azure Infrastructure Solutions
  • 70-346: Managing Office 365 Identities and Requirements
  • 70-347: Enabling Office 365 Services

A voucher can be redeemed to get register for one the above exams and this can be help to get Microsoft Certified Specialist in Azure or Microsoft Certified Solutions Associate in Office 365.

Visit http://borntolearn.mslearn.net/goodstuff/p/mcp.aspx to get a exam voucher and make sure to read the Terms and Conditions for Microsoft Certification Vouchers. Visit the Prometric website and provide voucher code to get register for exam.

0003.Surfer_5F00_facebook_5F00_400x209[1]

7651.dunk_5F00_facebook_5F00_400x209[1]

 

 

 

 

 

Download all Videos and Slides for SharePoint Conference 2014

For those who still not have downloaded the  SharePoint Conference 2014 sessions, they can download all sessions (videos and slides) using the PowerShell Script upload on Technet Gallery by Vlad Catrinescu.

The total size of script is 70 GB, if you have low bandwidth then

Download all Videos and Slides for SPC14

Download all Videos and Slides for SPC14

you can modify the script to download small size video files by selecting mp3 or mp4 files instead of mp4high (which have large file size). (Click here to download)

 

 

Powershell Script to download SharePoint Hybrid Courseware and Curriculum Video Series

SharePoint Hybrid Courseware and Curriculum is a video series on channel 9 which shows how to implement hybrid scenarios that use SharePoint Server 2013 and SharePoint Online in Office 365. I have uploaded PowerShell script from Technet Gallery which can be used to download all videos from SharePoint Hybrid Courseware Series. (Download Link)
Modules
The series consists of three Modules

  • Module 1: Understand the business value and rationale for a hybrid environment using SharePoint Server 2013 and SharePoint Online.
    • Module 1.1: Business Drivers and Considerations
  • Module 2: Guides you through the initial phase of the hybrid environment deployment process, which describes how to configure the basic infrastructure for a hybrid environment using SharePoint Server 2013 and SharePoint Online.
    • Module 2.1: Architecture, Authentication, and Functionality Overview
    • Module 2.2: Directory Synchronization with Single Sign-On for SharePoint hybrid
    • Module 2.3: Hybrid Environment Infrastructure for SharePoint hybrid
    • Module 2.4: Server-to-Server authentication and trust for SharePoint hybrid
  • Module 3: Understand the phases, solutions, and functionality that SharePoint Server 2013 and SharePoint Online hybrid environments support.
    • Module 3.1: Social for SharePoint hybrid environments
    • Module 3.2: Business Intelligence in a SharePoint hybrid environment
    • Module 3.3: Public Websites
    • Module 3.4: Extranets
    • Module 3.5: Core Collaboration and Records Management
    • Module 3.6: Search
    • Module 3.7: Business Connectivity Services

SharePointHybridCourseware

The attached script has the following key features

  • Downloads all the SharePoint Hybrid Courseware video series
  • Makes sure no errors come up due to Illegal File names.
  • If you stop the script and restart in the middle, it will start where it left off and not from beginning.

In this script I have added High MP4 videos to download which are larger in size and to download small size videos, you just need to change the variable values in the attached file.

# SharePoint Conference 2014 Videos
$a = ([xml]$rss.downloadstring(“http://channel9.msdn.com/series/SharePoint-Hybrid-Courseware-and-Curriculum/RSS/mp4high”))

#other qualities for the videos only. Choose the one you want!
# $a = ([xml]$rss.downloadstring(“http://channel9.msdn.com/series/SharePoint-Hybrid-Courseware-and-Curriculum/RSS/mp4”))
#$a = ([xml]$rss.downloadstring(“http://channel9.msdn.com/series/SharePoint-Hybrid-Courseware-and-Curriculum/RSS/mp3”))

Just add # sign before variable $a, as shown in above code (it will add it as comment) and then remove the # sign from any of the commented code. Just shown below.

# SharePoint Conference 2014 Videos
#$a = ([xml]$rss.downloadstring(“http://channel9.msdn.com/series/SharePoint-Hybrid-Courseware-and-Curriculum/RSS/mp4high”))

#other qualities for the videos only. Choose the one you want!
# $a = ([xml]$rss.downloadstring(“http://channel9.msdn.com/series/SharePoint-Hybrid-Courseware-and-Curriculum/RSS/mp4”))
$a = ([xml]$rss.downloadstring(“http://channel9.msdn.com/series/SharePoint-Hybrid-Courseware-and-Curriculum/RSS/mp3”))

Total Video Size:

The videos are not too large in length which make them easier to watch, total video size is 520 MB
Now run the script, and you will be able to download all videos of SharePoint Hybrid Courseware and Curriculum series.
(Download link)

Get detail report of all Documents in SharePoint site using Powershell

I have upload a Powershell script in Technet Gallery which will be very useful to get detail reports of all documents in a SharePoint Site Collection or site and sub sites. This script will list all document libraries which also system libraries (i.e. Master Page Gallery, List Template Gallery, etc.) and will list all documents in them.We have tested it on both SharePoint 2013 and SharePoint 2010 servers. (Click here to download the script file)

It contains a Function named Get-DocInventory which take single parameter i.e Site URL

Get-DocInventory "http://sp2013"

It will list the following properties of a document

  • Site URL
  • Web URL
  • Library Name
  • ID
  • Title
  • File URL
  • File Size
  • File Size (MB)
  • Modified Date
  • Modified By
  • Created Date
  • Created By

Check below image which show the detail report.

Get detail report of all Documents in SharePoint site using PowerShell

Get detail report of all Documents in SharePoint site using PowerShell

You can easily sort data by library name, title or by size.

There are two ways two execute this script, you can open script out put in grid view or can also export output in CSV format.

Run below command to get output in grid view:

Get-DocInventory "http://sp2013" | Out-GridView

Run below command to export output in CSV file:

      Get-DocInventory "http://sp2013" | Export-Csv -NoTypeInformation -Path c:\csv\Documents_Detail_Report.csv

(Click here to download the script file)

PowerShell Script to download all DotNet Conference 2014 Videos & Slides

DotNet conference was held in June 2014, I was downloading the videos and slides, downloading one by one takes too much time so I decided to share write powershell script which will download all available videos in DotNet Conference and will also download slides. I have uploaded script file in Technet Gallery and you can download it from this link.

Dot NET Conference 2014 downloads

Dot NET Conference 2014 downloads

The attached script has the following key features

  • Downloads all the DotNet 2013 Conference Sessions and Slides
  • Makes sure no errors come up due to Illegal File names.
  • If you stop the script and restart in the middle, it will start where it left off and not from beginning.

In this script i have added High MP4 videos to download which are larger in size and to download small size videos, you just need to change the variable values in the attached file.

# SharePoint Conference 2014 Videos 
$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/mp4high"))  
$b = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/slides"))  

#other qualities for the videos only. Choose the one you want! 
# $a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/mp4"))  
#$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/mp3"))

Just add # sign before variable $a, as shown in above code (it will add it as comment) and then remove the # sign from any of the commented code. Just shown below.

# SharePoint Conference 2014 Videos 
# $a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/mp4high"))  
$b = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/slides"))  

#other qualities for the videos only. Choose the one you want! 
 $a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/mp4"))  
#$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/dotnetConf/2014/RSS/mp3"))

Now run the script, and you will be able to download all videos & slides for DotNet 2014 Conference. You can download script from from Technet Gallery.

SharePoint 2013: Get Site information using PowerShell Script

I have uploaded a PowerShell Script on TechNet gallery, with that script you can get the site collection information which include Content DB details, count of current sub sites, and also size of each sub site, site collection and content DB. You can download and execute the script file using administrative rights on SharePoint Farm.

The output of file is saved in CSV format, which you can save it to any defined path.

The script contains 5 functions, the main function is GetGeneralInfo which generates all site information, it takes site URLS and output file path as parameter.

Function GetGeneralInfo($siteUrl, $OutputFile) 
{ 

#Write CSV- TAB Separated File) Header 
"Name `t Value" | out-file $OutputFile 

$ContentDB =  Get-SPContentDatabase -site $siteUrl 
$ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2) 

"Database Name  `t $($ContentDB.Name)" | Out-File $OutputFile -Append 
"Database ID  `t $($ContentDB.ID)" | Out-File $OutputFile -Append 
"Site count `t $($ContentDB.CurrentSiteCount)" | Out-File $OutputFile -Append 
"Site count `t $($ContentDB.MaximumSiteCount)" | Out-File $OutputFile -Append 
"Can Migrate `t $($ContentDB.CanMigrate)" | Out-File $OutputFile -Append 
"Content DB Size `t $($ContentDatabaseSize) GB" | Out-File $OutputFile -Append 
"Database Servername `t $($ContentDB.Server)" | Out-File $OutputFile -Append 
"Connection String `t $($ContentDB.DatabaseConnectionString)" | Out-File $OutputFile -Append 
"Display Name `t $($ContentDB.DisplayName)" | Out-File $OutputFile -Append 
"Schema `t $($ContentDB.SchemaVersionXml)" | Out-File $OutputFile -Append 

GetWebSizes -StartWeb $siteUrl 
}

The function call is quite simple as below:

GetGeneralInfo "http://spFarm" "C:\GeneralInfo.csv"

The basic detail of the site collection is fetched from Get-SPContentDatabase class, and sub site and site collection size is fetched from remaining functions which is calculated all files in the document libraries.

If you feel any difficulty on running this script then do update me.

This script has been tested on SharePoint 2010 and SharePoint 2013