Friday, September 14, 2012

SharePoint Powershell Test Data script

Scenario:
Working on a project and we need to test the software limit of SharePoint 2010.
MS Documentation is not clear about things/ community blogs have different experience.
So without taking chance, here a small script to create test items

Solution:
Powershell script

Code:

cls
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

$webUrl = Read-Host 'Please specify site url'
$web = Get-SPWeb $webUrl;
$list = $web.Lists.TryGetList("Announcements");
(1..50000)|%{
$item = $list.Items.Add();
$item["Title"]="Test";
$item.Update();
# Optional 
# $item.BreakRoleInheritance($True);
$item.ID
}
$web.Dispose()

0 comments: