Tuesday, December 27, 2011

Hyper V VM failed to set/change partition property error

Tried setting up a virtualized web farm in machine which is running Intel i5 with Windows Server 2008 R2 standard RTM. Hyper V manager refused to start a virtual machine in a brand new host machine. It has got enough of memory and CPU cores to start the virtual machine.

It keep on showing VM could not initialize < VM Guid > and "failed to set/change partition property" in event viewer.

After an hour of googling found a KB 2517374 article with reference about Intel AVX technology in Sandy bridge processors and some interesting stuff from Jeff Woolsey's Chicken and egg case.

The base funda is Intel's sandy bridge processors were released after the release of Windows Server 2008 R2 RTM, so it doesn't contain the bits to leverage new bells and whistles. As there is a slight change in processor architecture itself, it refuses to start the virtual machines.

Either upgrade to Service pack 1 to make use of Intel AVX in host and guest or install the above mentined hotfix to disable the AVX for the guest OS's

Upgrade to service pack 1 and enjoy the power of AVX(high performance floating point calculations) in both of your guest and host.

Friday, December 23, 2011

SharePoint List items bulk delete

Recently while working on a production case, we needed to delete around 2000 list items in a single shot. My idea was to use the data sheet view ActiveX control to do the bulk delete. But in production case where the server runs on 64 bit and clients run on 32 bit, there was problem invoking the ActiveX control and shared  the following snippet to do a batch delete.

private static void deleteAllListItems(SPSite site, SPList list)
StringBuilder sbDelete = new StringBuilder();
sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");
string command = "<Method><SetList Scope=\"Request\">" + list.ID + "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar     Name=\"Cmd\">Delete</SetVar></Method>";
foreach (SPListItem item in list.Items)
sbDelete.Append(string.Format(command, item.ID.ToString()));
Console.WriteLine("now deleting");

This snippet deletes that huge list much faster than traditional object model way.