Friday 4 November 2011

SharePoint and DPM Protection

Been tasked with setting up and configuring DPM (Microsoft Data Protection Manager 2010) to provide disaster recovery and granular backups to a domain of development servers.

The domain its self has everything, domain controllers, exchange, sql cluser(s), sharepoint 2007 multi server farms, sharepoint 2010 multi server farms and plenty of single server instances to worry about. The domain is a virtualised domain with some impressive tin and plenty of resources so its used globably by the company i work for.

I've been using my increasing powershell kung fu to automate and batch most of the process but before I write some posts about what i'm doing and how - on a farm this big I needed to make sure I knew the basics of DPM and specifically doing it for Sharepoint.

I found a fantastic post that helps me do just that and wanted to share.

http://scug.be/blogs/scdpm/archive/2010/03/11/sharepoint-2010-protection-in-dpm-2010-part-1.aspx


Have fun!

Wednesday 26 October 2011

Update SharePoint User Profile for all users in a Active Directory Distribution List

Putting my 2010 project work aside, I was asked to programmatically update each users "User Profile" that was a member of a group (Distribution List) in active directory. In my case, I had to create a custom user profile property called "location". I then had to map each person from their DL in AD to a location in their user profile.


So if I am based in "Glasgow" and I am in the Active Directory Group "Scotland_All" - they wanted some code to update my user profile property, on a mass scale (12,000 users)..


I did some googling before i set about the task but didn't find very much so figured i'd post a quick how-to.


First I went through active directory to get all users that were a member of X group.





const string ADaddress = "domain.com";

const string ADuserName = @"domain\admin";

const string ADPassword = "DomainAdminPassword";

const string ad_group = "Xgroup";

const string domain_name = "Domain"; //not entirely needed

const string sp_site = "http://yourSharePointSite.domain.com";

const string location_value = "Value";




I had to use an account and password with access to AD.






try

{

//Create connection to AD and get all users in specified group

PrincipalContext ctx = new PrincipalContext

(ContextType.Domain,

ADaddress,

ADuserName,

ADPassword);



//Search for members in group

GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, ad_group); //CL_France being the DL we need

PrincipalSearchResult members = group.GetMembers(); //getting them all



//Get the user names and add the domain (we are assuming that all these users will be "s7")

foreach (Principal member in members)

{

string domainUserName = domain_name + @"\" + member.SamAccountName;



//Update in Sharepoint

UpdatespProfile(domainUserName);

}

}

catch (Exception ex)

{

Console.WriteLine(ex); //show me the error

Console.Read(); //pause



}

}




Once have the users details, I start updating their user profile. This is done using the object model so the console app was run locally. It can be done via web services but with so many users and transactions I found that simelar tasks would time out..





//take user names, check they have a user profile - if they do, update "localtion" field

static void UpdatespProfile(string uName)

{

//show user in console

Console.WriteLine(uName);//member.SamAccountName);



try

{



using (SPSite site = new SPSite(sp_site))

{

//Connect to user manager and pass in user name

UserProfileManager profileManager = new UserProfileManager(ServerContext.GetContext(site));

UserProfile userProfile = profileManager.GetUserProfile(uName);



//check if we have a valid user profile

if (userProfile != null)

{



//Update location field

userProfile["Location"].Value = location_value;


//update the user profile

userProfile.Commit();



//show it worked in console

Console.WriteLine("Updated Location to" +" " + location_value);



}

else

{

//show we didn't have a valid user profile in console

Console.WriteLine("No user profile");

}

}

}

catch (Exception ex)

{

//show the error

Console.WriteLine(ex);

//pause

Console.Read();

}

}



Works very nicely. Hope someone out there finds it useful.

Thursday 25 August 2011

Upcoming Posts

Having started a new contract last month working predominately on the infrastructure, administration and consultancy side of SharePoint I am missing development a little but in the meantime getting my hands very dirty with some work i'll be blogging in the near future.

I have been particularly working with Powershell, Hyper-V and SharePoint.

Recently I designed and implemented a full new Development lab infrastructure which allows new stand-alone SharePoint 2010 servers to be deployed in Hyper-V with almost 0 configuration from the deployment agent.

In otherwords, I have scripted and automated the entire process using Poweshell with the following processes automated:

  • New Virtual Machine created from clone of base server
  • New virtual machine configured
  • Powershell scripted configuration of the operating system installation
  • powershell scripted configuration of networking, renaming the machine, joining the domain
  • Powershell scripted configuration of a Sql server 2008 pre-deployment image
  • Powershell scripted installation of SharePoint 2010
  • Powershell scripted configuration of SharePoint 2010 configuration database and new farm
  • powershell scripted deployment of new SharePoint 2010 farm
  • powershell scripted deployment of web applications and site collections
  • powershell scripted configuration of SSP
  • Powershell scripted configuration of search services
  • powershell scripted server security configs, terminal services and so forth
  • powershell scripted assignment of Alternate access mappings to allow remote access

Basically a fully functioning development lab, fully scripted and deployed in less than 1 hour with no manual overhead for the user other than initiation the process.

I hope to blog most of the process, in particular the scripts them selves and while many other people have deployed similar scripts, the dynamic nature of this type of deployment means they can be re-used in many scenarios.




Friday 28 January 2011

New laptop



It's come time to get a new work laptop - I've always been a DELL man, having worked there twice in my career - first as a tech support guy for their laptops and onwards into software.

I was looking at the DELL XPS laptops and reviews. My old one was an XPS M1730 - At the time I got it one of the best laptops on the market. Was fantastic for gaming, Virtual machines, had a huge screen but it was also exceptionally large and heavy. It was also quite flashy with glowing vents and XPS logos etc. The screen was amazing and had a really high resolution for a laptop. This allowed me to work without feeling constricted.

Having reviewed all the newer "slicker" XPS laptops I am torn between the new XPS 17 laptop. It looks really sleek, has a great spec and doesn't require weightlifting training to carry it around!


Nice hi res screen, good graphics card and sound engine along with a fairly good spec.

however.. At the same time, I am a huge fan of Alienware. I own the Area51 ALX Desktop - easily the most powerful, coolest looking home gaming computer on the market and I am tempted to go for the new Alienware M17x Laptop




Everything about this laptop is "cool" - its extremely powerful with a standard build of 6gb of ram, a TB of hard disk space on a raid array. I7 processor with. its also very durable and the screen is not only 1200p but has 3d capability.

I'll decide at the weekend which one I am going to buy - I like new toys and from a work perspective; either of these laptops will handle pretty much anything I throw at them. The only drawback is the price. The alienware is almost £1000.00 more expensive!


*edit:

Went with the XPS :)

2.93 ghz CPU i7 Quad Core
16 GIG DDR
500 GB Hard Drive
Windows 7 Ultimate 64BIT
3GB Graphic Card
Built in Wireless
DVDRW / BluRay
UK Spec
USB 3.0 Technology
9 Cell Battery
JBL 2.1 Designed & Certified Speakers +Waves MaxxAudio®
2.1 Audio: 2 X 5W + 12W sub-woofer 22W Total
Integrated Camera
15 Months McAfee Anti Virus
Computrace LoJack so it can't get pinched :)