Thursday, November 17, 2011

How to save a site as template using PowerShell

Here is Powershell script to save a site as template.

$SiteUrl = "http://Sharepoint2010/site"
$Web=Get-SPWeb $SiteUrl
$Web.SaveAsTemplate("Template Name","Template Title","Template Description",1)

The last parameter of SaveAsTemplate() can be 0 or 1. 1 if you want to save the site with data else 0.
Make sure you open the SharePoint Management Shell as Administrator.

Error - "MOSS MA not found”

Yesterday I got his error "MOSS MA not found”  while creating the connector for User Profile synchronization in SharePoint 2010.

To fix that -
I restarted the Forefront Identity Manager Service and the Forefront Identity Manager Synchronization Service.

To find those services
Run > Services.msc > Forefront Services > right click and select restart. 
If services do not start, You may need to enter service account/password on Logon Tab of service properties screen.

Hope this help!

How to Hide search box

There are ways to hide the search box. 

1. If you can edit master page, just set ‘visible’ property of Serachbox control to false. (DONOT Edit OOTB SharePoint master page and may cause issues in other areas.)

<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4" Visible="false"/> 

2. You can use CSS to hide the Searchbox by setting the display property to none. Add this to custom css file.
#s4-searcharea { display:none; }

If you want to hide search box in a specific page then you can use Content Editor webpart and place CSS code like this. 
<style>
#s4-searcharea { display:none; }
</style>

How to Hide a List using PowerShell

Last week i had a requirement to hide a list from user view. To achieve that, I used PowerShell to hide a list in SharePoint 2010 by setting hidden property of SPList Object to $true.

Here is the script -

#--- Update these variables -----
$SiteUrl = "http://Sharepoint2010/site"
$ListURL = "http://Sharepoint2010/site/Lists/ListToHide"
#-------------------------------------


$Web = Get-SPWeb $SiteUrl
$List = $spWeb.GetList($ListURL)
$List.Hidden = $true
$List.Update()