Monthly Archives: May 2014

SharePoint PowerShell How To: Create SharePoint List Items (in Root and in Folders) for Load/Performance Testing

SharePoint PowerShell How To Series – Foreword

I often find myself scratching around the local drive of my development machines for remnants of PowerShell scripts to generate list & libraries in SharePoint with all sorts of different folder hierarchies to test the performance of code I’m working on to ensure it scales well once the folder & item counts start getting up to high numbers. So rather than keep scratching I’m going to start posting my scripts as I create and use them so I can find/reuse them later on and someone else might find them useful as well. I’m sure they won’t work under all scenarios and situations (and they are not designed to). They are just quick scripts that serve a specific purpose to me at the time and you may be able to tweak to fit your needs.

Create list items in the root of a custom SharePoint list

Script description: Creates 10,000 list items in the root folder of the “OnePlace License R7” list of the site located at the URL “vs-server38”.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

# Script settings
$webUrl = "http://vs-server38"
$listName = "OnePlace Licenses R7"
$numberItemsToCreate = 10000
$itemNamePrefix = "License "

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

# Create desired number of items in subfolder
for($i=1; $i -le $numberItemsToCreate; $i++)
{
$newItemSuffix = $i.ToString("00000")
$newItem = $list.AddItem()
$newItem["Title"] = "$itemNamePrefix$newItemSuffix"
$newItem.Update()
write-host "Item created: $itemNamePrefix$newItemSuffix"
}

#Dispose web
$web.Dispose()

Create list items in a folder of a custom SharePoint list

Script description: Creates 10,000 list items in the “OnePlaceDocs” folder of the “OnePlace License R7” list of the site located at the URL “vs-server38”.

Note: this assumes you have already created a folder called “OnePlaceDocs”in the list.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

# Script settings
$webUrl = "http://vs-server38"
$listName = "OnePlace Licenses R7"
$subFolderName = "OnePlaceDocs"
$numberItemsToCreate = 10000
$itemNamePrefix = "License "

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

# Get handle on the subfolder
$subFolder = $list.RootFolder.SubFolders.Item($subFolderName);

# Create desired number of items in subfolder
for($i=1; $i -le $numberItemsToCreate; $i++)
{
$newItemSuffix = $i.ToString("00000")
$newItem = $list.AddItem($subFolder.ServerRelativeUrl, [Microsoft.SharePoint.SPFileSystemObjectType]::File, $null)
$newItem["Title"] = "$itemNamePrefix$newItemSuffix"
$newItem.Update()
write-host "Item created: $itemNamePrefix$newItemSuffix"
}

#Dispose web
$web.Dispose()

Others articles in this series:

What’s the difference between a UX designer and a UI designer?

I love this infographic, quickly sums up the differences (and similarities) between a UX designer and a UI designer.

[Click the image to see full size]

UX-designer-vs-UI-designer-difference-and-similarites-Infographic

Solving the “Boot Failed. EFI SCSI Device” error when installing Windows 2012 Server on Hyper-V

I’ve installed Windows 2012 server on a few Hyper-V images in the past but ran into an error that looked unfamiliar. I created my Hyper-V machine, configured it with a dynamic hard drive, added a DVD and mounted the Windows Server 2012 ISO making sure the DVD drive was top of the boot order and started it up.

cameron-dwyer-install-windows-2012-server-hyperv-boot-failed-EFI-SCSI-Device

I was then presented with a black screen an the error message:

Boot Failed. EFI SCSI Device.

cameron-dwyer-install-windows-2012-server-hyperv-boot-failed-EFI-SCSI-Device-Error-On-Startup

Here’s the long winded explanation from the Senior Program Manager of the Hyper-V team (John Howard).

The short answer: It’s because the virtual machine was created as a Generation 2 machine rather than Generation 1.

cameron-dwyer-install-windows-2012-server-hyperv-specify-machine-generation-2

To get past this error simply hold down a key as you start up the virtual machine. You’ll notice at the top of the error screen it says “Press any key to boot from CD or DVD…..” the issue is that it doesn’t wait for you to press a key, just make sure you have a key held down when it gets to this point and you should see the Windows Boot Manager prompt allowing you to boot to the DVD image.

cameron-dwyer-install-windows-2012-server-hyperv-boot-failed-EFI-SCSI-Device-Windows-Boot-Manager

Then hey presto you’ll get a successful boot to DVD and the Windows Setup window you expected.

cameron-dwyer-install-windows-2012-server-hyperv-boot-Windows-Setup

%d bloggers like this: