By default a SharePoint 2010 publishing site uses default.aspx as its welcome page. There are so many conditions where we use our custom web part page as the default page for our publishing site in place of general default.aspx. The best example for this is an application dashboard as the default page. Though its very easy to set the welcome page in a SharePoint site by navigating to Site Settings and under Look and Feel section click on Welcome Page.
Now the question is why i wrote power-shell script for such a simple task.
Answer 1: I want a one click deployment solution for my custom code that includes features, event receivers, web parts etc. I don’t want to remember steps, just i run a batch file and execute everything inside from that batch file.
Answer 2: In my solution i have custom pages and i wrote the deployment script to create those pages. During development if we change any page for java-script, CSS etc. then we need to redeploy the pages to check the implementation. So we need to delete all pages first and then redeploy them otherwise pages so the double instance of each web parts inside that. Well we know that you can’t delete a page directly that is set as welcome page in SharePoint site so in this case you need to set another page as welcome page first then delete the page you want to. So during my development cycle this was very irritating that before deployment of my custom pages i need to first set Under_Construction.aspx page as my welcome page then delete my actual welcome page then deploy custom pages and then again set the actual page as welcome page. What is your machine is slow and after any deployment it runs pathetically slow..
Oh my god it sucks.. So for all this i wrote a script to set welcome page so that before and after the deployment of pages i could run this and rest of the work it do automatically. So below is the script:
$web=Get-SPWeb -Identity “http://kailash1689new:9007” -AssignmentCollection $assignment
Write-Host ‘Welcome Page Set Successfully…’
Write-Host ‘Press any key to exit…’