In Part 1 of this series we have explored PowerShell basics and how to use it with SharePoint 2010.
Now let’s discover how to write PowerShell script to access SharePoint objects and perform some operations
Create Site collection
The following PowerShell script will Create 10 Site collections under sites managed path from the team site template
We used New-SPSite cmdlet inside for loop and passed as parameters the site URL, Site owner, template id and site language
cmdlets used: New-SPSite
Add items to Announcements list
our second script is to add items to announcements list which can be helpful if you want to add a lot of items in a list for demo or development or testing purposes
In this script we retrieved the web object then through object properties we retrieved the list by its title and through for loop we added new item in each loop.
cmdlets used: Get-SPSite, Get-SPWeb
Tags: PowerShell, SharePoint 2010