Sunday, January 20, 2013
SharePoint Content DB size mismatch
Hi,
Once you enable the quota limit in central admin for a site collection and do check the _layouts/storman.aspx page, you are able to see the site storage space.
But, you may find some difference in the actual content db size and the statistics shown in the above page.
To recalculate it again, use the below power shell script.
$site=get-spsite -identity http://sitecollectionurl
$site.RecalculateStorageUsed()
Saturday, January 19, 2013
Back up the farm using power shell
I got a requirement from my client to take the backup of the farm on a weekly basis using automated scheduler.
we do have a standard powershell cmdlet, that helps us in taking the back up of farm using backup-spfarm cmdlet.
We could do the job on a dialy or weekly basis with power shell script and windows task scheduler.
After I searched for some time , I got an excellent blog from http://sharepointpolice.com/ .
Here is the same script , I used for my farm.
we do have a standard powershell cmdlet, that helps us in taking the back up of farm using backup-spfarm cmdlet.
We could do the job on a dialy or weekly basis with power shell script and windows task scheduler.
After I searched for some time , I got an excellent blog from http://sharepointpolice.com/ .
Here is the same script , I used for my farm.
How to hide recently modified documents in the masterpage
Hi All,
Just want to note my small work on hiding recently modified document link in the sharepoint site.
If you want to do it for all pages in the site, go to master page of the site using designer and write the below css snippet in the head tag.
If you want to hide the same for a particular home page only,
add the same css in CEWP webpart.
Hide fields in the list view web part using jquery
Hi Guys,
I had a requirement to hide the list fields in the list view web part.
For example, in a workflow, I have a course training custom list with multiple columns, where the students want to enter their data like name, course required, timings etc and course faculty need to see additional fields like approved/rejected, his availability etc.
For students, they should not see approved column while they submit the course request.
This could be possible through a simple j query, in a content editor web part with specifying target audience.
Here is the jquery code.
$('nobr:contains("Approved")').closest('tr').hide(); //"Approved" is your required column to hide.
The code works like this
When you go to view source of the page, you could see the fields names with the tag "nobr" associated to it. So query those tags with jquery selector and hide its nearest 'tr'.
So if the above code does not work for you, make sure to check the view source of the page and see the field name tags.
I had a requirement to hide the list fields in the list view web part.
For example, in a workflow, I have a course training custom list with multiple columns, where the students want to enter their data like name, course required, timings etc and course faculty need to see additional fields like approved/rejected, his availability etc.
For students, they should not see approved column while they submit the course request.
This could be possible through a simple j query, in a content editor web part with specifying target audience.
Here is the jquery code.
$('nobr:contains("Approved")').closest('tr').hide(); //"Approved" is your required column to hide.
The code works like this
When you go to view source of the page, you could see the fields names with the tag "nobr" associated to it. So query those tags with jquery selector and hide its nearest 'tr'.
So if the above code does not work for you, make sure to check the view source of the page and see the field name tags.
Thursday, November 1, 2012
SharePoint 2010 Birthday webpart
Hi ,
I had a small requirement from my manager to display the team mates birth days in the team site for the current month.
I searched for the already existing solutions in the net and able to replicate one of them using a simple OOB approach.
You just need a custom list to store the team mates names and birth day dates and need to do some calculated columns . Thats enough.
Below are the steps explained.
I had a small requirement from my manager to display the team mates birth days in the team site for the current month.
I searched for the already existing solutions in the net and able to replicate one of them using a simple OOB approach.
You just need a custom list to store the team mates names and birth day dates and need to do some calculated columns . Thats enough.
Below are the steps explained.
- Create a custom list named TeamBirthdayList and add the columns name, birthday as date type and other details if needed to display like mail id and mobile no.
- create a column named "currentdate" and make default value as today's date with date only.
- Create two calculated columns named "startmonth" and "endmonth".
- startmonth calulated formula as DATE(YEAR(currentdate),MONTH(Birthday),1)
- endmonth calulated formula as DATE(YEAR(currentdate),MONTH(Birthday)+1,1)-1.
- Now create another column named "BirthdayOrder" as calculated column to sort the list according to the date. the formula will be like this : DATE(YEAR(currentdate),MONTH(birthday),DAY(birthday))
- Now, add this list as listview webpart in the page and change the view settings like below steps.
- Sort the items as per birthday order field .
- IN the filter section, startmonth is less than or equal to [Today] and endmonth is greater than or equal to [Today]
Saturday, October 20, 2012
SharePoint 2010 calendar color indiacator using Overlays
Hi Guys,
Recently I got a requirement from my team to develop vacation calendar along with color indicators for each category.
Later started search, I found many good articles on the internet, but I want to finish through OOTB. So I got the below method to work exactly and writing down the below lines to be helpful for others and for my own tracking .
Step1: Create one calendar list and name it as vacation calendar. Once created, go to settings and then change category choice items. Add your own categories upto 7 ( as OOTB offers not more than this colors). For e.g. I created 3 categories named "Vacation", "Training", "Work from Home"
Step2: Create a new calendar view named Vacation view and specify Category is equal to Vacation in filter section.
Step 3: Create other 2 views like in step 2 with specifying categories is equal to their category values.
Step 4: Create a new view name Overlay view and specify Category is blank in Filter section..
Step 5: Create Overlay view as the default view and click on Overaly button in ribbon.
Step 6: Create new calendar link in Overlay section and specify names and select appropriate site with click on resolve button.
Specify the color from the list and fill the remaining details.
Thats it. Try adding different entries with various categories and you can find different colors. Make sure Overlays view is your default view, so that when you add it as list view webpart, make sure to change the view to Overlay view in tool bar setting.
You would get final look and feel like this,
Cheers,
Anil
Recently I got a requirement from my team to develop vacation calendar along with color indicators for each category.
Later started search, I found many good articles on the internet, but I want to finish through OOTB. So I got the below method to work exactly and writing down the below lines to be helpful for others and for my own tracking .
Step1: Create one calendar list and name it as vacation calendar. Once created, go to settings and then change category choice items. Add your own categories upto 7 ( as OOTB offers not more than this colors). For e.g. I created 3 categories named "Vacation", "Training", "Work from Home"
Step2: Create a new calendar view named Vacation view and specify Category is equal to Vacation in filter section.
Step 3: Create other 2 views like in step 2 with specifying categories is equal to their category values.
Step 4: Create a new view name Overlay view and specify Category is blank in Filter section..
Step 5: Create Overlay view as the default view and click on Overaly button in ribbon.
Step 6: Create new calendar link in Overlay section and specify names and select appropriate site with click on resolve button.
Specify the color from the list and fill the remaining details.
Check Always show check box.
Step 7: Create another two calendar in Calendars Overlay section using above step for other two cateogories.Thats it. Try adding different entries with various categories and you can find different colors. Make sure Overlays view is your default view, so that when you add it as list view webpart, make sure to change the view to Overlay view in tool bar setting.
You would get final look and feel like this,
Cheers,
Anil
Sunday, October 14, 2012
Powershell startup
Hi Guys,
I started learning powershell scriping recently and I noted my learning updates here for quick reference
If you are unable to add snapin to the powershell console, you may not have sufficient permissions to do the scripting.
Here are the steps to get the permissions to run the scripts.
You should have access to sharepoint shell configuration database and here is the cmdlet.
Add-SPShellAdmin -username contoso\user1
You have to perform the above step by using farm administrator privileges. The above command adds the user name specified to the Sharepoint_shell_access role on the configuration database.
If you want to give permission to a specific content database for a webapplication, specify the database parameter
Add-SPShellAdmin -username contoso\user1 -database guid
2. To get help on any command,
help Get-SPSite
3. To get examples on the cmdlet.
Get-SPSite -examples
4. To get information about the site,
Get-SPSite http://litware | select owner, Name, Description
5. To know about the features in a site collection
Get-SPFeature -site http://litware
6. To activate the features
Enable-SPFeature -identity GUID -url http://litware
7. To install the feature,
Install-SPFeature featurename
e.g Install-SPFeature MyCustomFeature
Before installing the feature, make sure that, the feature files are deployed correctly in 14 hive features folder.
8. To add the solution to the farm,
Add-SPSolution solutionname
e.g. Add-SPSolution "D:\mycustomsolution.wsp"
9. To deploy the solution to the GAC
Install-SPSolution -identity mycustomsolution.wsp -webapplication http://litware -GACdeployment
10. To update the solution
Update-SPSolution -identiy mycustomsolution.wsp -literalpath "d:\mycustomsolution.wsp" -GACdeployment
11. To uninstall the solution from the web application
Uninstall-SPSolution -identity mycustomsolution.wp -webapplication http://litware
12. To remove the solution from farm
Remove-SPSolution -identity mycustomsolution.wsp
Below is the example
Powershell script to install a feature for all the site collections in a farm with known GUID
Add-PSSnapin microsoft.sharepoint.powershell
$webapplications=Get-SPWebapplication
foreach($webapp in $webapplications)
{
$id=$webapp.id;
write-host "processing webapplication with name, id" + $webapp.Name, $id
foreach($site in $webapp.Sites)
{
$name=$site.Name;
write-host "processing site collection -" + $name
foreach($web in $site.AllWebs)
{
write-host "processing web" +$web.title
$features=$web.features;
if($web.features[GUID] -eq $null)
{
enable-spfeature -identity GUID -url $web.url -confirm:$false
}
}
}
}
I started learning powershell scriping recently and I noted my learning updates here for quick reference
- To add powershell snap-in
If you are unable to add snapin to the powershell console, you may not have sufficient permissions to do the scripting.
Here are the steps to get the permissions to run the scripts.
You should have access to sharepoint shell configuration database and here is the cmdlet.
Add-SPShellAdmin -username contoso\user1
You have to perform the above step by using farm administrator privileges. The above command adds the user name specified to the Sharepoint_shell_access role on the configuration database.
If you want to give permission to a specific content database for a webapplication, specify the database parameter
Add-SPShellAdmin -username contoso\user1 -database guid
2. To get help on any command,
help Get-SPSite
3. To get examples on the cmdlet.
Get-SPSite -examples
4. To get information about the site,
Get-SPSite http://litware | select owner, Name, Description
5. To know about the features in a site collection
Get-SPFeature -site http://litware
6. To activate the features
Enable-SPFeature -identity GUID -url http://litware
7. To install the feature,
Install-SPFeature featurename
e.g Install-SPFeature MyCustomFeature
Before installing the feature, make sure that, the feature files are deployed correctly in 14 hive features folder.
8. To add the solution to the farm,
Add-SPSolution solutionname
e.g. Add-SPSolution "D:\mycustomsolution.wsp"
9. To deploy the solution to the GAC
Install-SPSolution -identity mycustomsolution.wsp -webapplication http://litware -GACdeployment
10. To update the solution
Update-SPSolution -identiy mycustomsolution.wsp -literalpath "d:\mycustomsolution.wsp" -GACdeployment
11. To uninstall the solution from the web application
Uninstall-SPSolution -identity mycustomsolution.wp -webapplication http://litware
12. To remove the solution from farm
Remove-SPSolution -identity mycustomsolution.wsp
Below is the example
Powershell script to install a feature for all the site collections in a farm with known GUID
Add-PSSnapin microsoft.sharepoint.powershell
$webapplications=Get-SPWebapplication
foreach($webapp in $webapplications)
{
$id=$webapp.id;
write-host "processing webapplication with name, id" + $webapp.Name, $id
foreach($site in $webapp.Sites)
{
$name=$site.Name;
write-host "processing site collection -" + $name
foreach($web in $site.AllWebs)
{
write-host "processing web" +$web.title
$features=$web.features;
if($web.features[GUID] -eq $null)
{
enable-spfeature -identity GUID -url $web.url -confirm:$false
}
}
}
}
Subscribe to:
Posts (Atom)