Wednesday, October 31, 2012

Find application Pool name from GUIDs - SharePoint 2010


Last week I was investigating an issue about Project server 2010 install on SharePoint 2010. I was looking for which application pool is used for Project server service application. As application pools are shown as GUIDs it’s hard to tell which application pool is used for which service application. These GUIDS are unique to each environment that causes some issues when troubleshooting.

So if you want to find out which App Pool in IIS is which App Pool in SharePoint run this command in SharePoint Management PowerShell 

Get-SPServiceApplicationPool | select Id, Name

Get-SPServiceApplicationPool lists all of the SharePoint application pools.

To remove one, you would just type:

Get-SPServiceApplicationPool -Identity [name of app pool] | Remove-SPServiceApplicationPool

Run each time Get-SPServiceApplicationPool to verify if it has been deleted.
 

Wednesday, September 12, 2012

Hide a column from List Edit Form



I wanted to hide a column from Edit form of a specific list   

function Hide-SPField([string]$url, [string]$List, [string]$Field) {
 [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
 $SPSite = New-Object Microsoft.SharePoint.SPSite($url)
 $OpenWeb = $SPSite.OpenWeb()
 $OpenList = $OpenWeb.Lists[$List]
 $OpenField = $OpenList.Fields[$Field]
 $OpenField.ShowInNewForm = $True
 $OpenField.ShowInEditForm = $False
 $OpenField.ShowInViewForms = $True
 $OpenField.ShowInDisplayForm = $True
 $OpenField.Update()
 $SPSite.Dispose()
 $OpenWeb.Dispose()
 }

 Hide-SPField -url http://yoursite.com/ -List "ListName" -Field "ColumnName"

If you want to hide column in forms across the entire site. you need set the PushChangesToLists property for the changes to be applied to lists where the column has already been added.




#Get the web and site column objects
 $web = Get-SPWeb "http://yoursite.com
 $column = $web.Fields["ColumnName"]
$column.PushChangesToLists = $true
 #Change the ShowInForm property and update objects
 $column.ShowInEditForm = $False
 $column.ShowInNewForm = $False
 $column.ShowInViewForms = $False
 $column.ShowInDisplayForm = $False
 $column.Update()
 $web.Update()
 $web.Dispose()





Move Site Collections between Content Databases



In MOSS 2007 one of content database has grown beyond 100 GB. So I wanted to move couple of existing site collections to another content DB. So I used STSADM to move them.

You can retrieve all the site collections from the source content database using this stsadm command. It will generate a file sites.xml.
stsadm -o enumsites -url http://webAppURL/ –databasename Your_Content_DB > sites.xml

Open sites.xml and remove the sites that you keep in source database. You need to keep site collections entry that you want to move to destination content database. Save the file.
Now run this command to move site collections to another content database.
Merge databases:
stsadm -o mergecontentdbs -url http://webAppURL/ -sourcedatabasename <SourceDB>  -destinationdatabasename <DestinationDB> -operation 3 -filename mysites.xml

In SharePoint 2010 we can achieve the same using PowerShell.
Move-SPSite <URLofSiteColletion> -DestinationDatabase <DestinationDB>