There would be performance issues coming up in a server where we find that the server memory is being consumed by unnecessary processes. In order to prevent its unnecessary memory consumption, We can use the below powershell script which shall kill the process that consumes 100000000 KB of memory.
$computer = "mymachine"
$a = Get-Process -ComputerName $computer
$objs = $a | where-object {$_.WorkingSet -gt 100000000}
$processes = $objs | select {$_.ProcessName}
$i = $processes.Count
for ($k = 0; $k -lt $i; $k++)
{
$obj=get-wmiobject -comp $computer -query "select * from win32_process where name=$processes[$k]"
$obj.Terminate()
}
Hope this helps....
Monday, March 22, 2010
List of services running on the server using PowerShell
As a systems administrator, there would always be a requirement for us to check if the particular services in the servers are running on that. To fix this, we can use the powershell script which shall give us the list of services running on a particular server and its status. We can also have a list of servers and get the powershell script run which would give details of the services from all the servers, We need to make sure that the account using which you would run this script is an administrator on all the servers on which you want to validate.
The powershell script is
$a = get-wmiobject win32_service -ComputerName "mymachine"
$a | select name,startname,startmode,state
Hope this helps....
The powershell script is
$a = get-wmiobject win32_service -ComputerName "mymachine"
$a | select name,startname,startmode,state
Hope this helps....
Monday, March 15, 2010
Configuration Database details in Registry of the Sharepoint Server
For MOSS 2007, we can find the details about the configuration database and the SQL server where it's hosted in the below path in the registry of the sharepoint server.
HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDb
This path is applicable for WSS 3.0 also.
When we are planning for the migration of the SQL server and we face any issue during that, we can validate if the sharepoint is pointing to the correct SQL server or not from the above path.
Hope this helps someone.
HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDb
This path is applicable for WSS 3.0 also.
When we are planning for the migration of the SQL server and we face any issue during that, we can validate if the sharepoint is pointing to the correct SQL server or not from the above path.
Hope this helps someone.
Monday, March 1, 2010
Configuring FBA in MOSS 2007
What is LDAP?
Many a times this question comes up and how can we integrate it with Sharepoint. LDAP stands for Light Directory Access Protocol. In sharepoint, its equivalent to FBA i.e. Form Based Authentication.
FBA in Sharepoint is always recommended for Extranet sites and for the internet sites. The reason for not setting up it in intranet is very nicely explained by Nick in his blog http://planetmoss.blogspot.com/2009/02/using-ldap-authentication-with.html .
Well, coming to configuration for the FBA, I configured it following the steps from the site http://www.fivenumber.com/configuring-ldap-authentication-in-moss-2007/ and this worked as a charm for me.
I am providing the details in brief -
1> Create a website and extend it. Once the website is extended, select authentication as NTLM.
2> Copy and paste the tags which are basically the membership provider registration as mentioned in the site above. make sure that you provide your server name in the tags.
3> Once done, go to Central Administration > Application Management > Authentication Providers
Click on the extended web application, then select authentication type as Forms.
4> then click on Save.
5> Add the LDAP user. Once done, try to access the extended site using the LDAP user that was added.
Many a times this question comes up and how can we integrate it with Sharepoint. LDAP stands for Light Directory Access Protocol. In sharepoint, its equivalent to FBA i.e. Form Based Authentication.
FBA in Sharepoint is always recommended for Extranet sites and for the internet sites. The reason for not setting up it in intranet is very nicely explained by Nick in his blog http://planetmoss.blogspot.com/2009/02/using-ldap-authentication-with.html .
Well, coming to configuration for the FBA, I configured it following the steps from the site http://www.fivenumber.com/configuring-ldap-authentication-in-moss-2007/ and this worked as a charm for me.
I am providing the details in brief -
1> Create a website and extend it. Once the website is extended, select authentication as NTLM.
2> Copy and paste the tags which are basically the membership provider registration as mentioned in the site above. make sure that you provide your server name in the tags.
3> Once done, go to Central Administration > Application Management > Authentication Providers
Click on the extended web application, then select authentication type as Forms.
4> then click on Save.
5> Add the LDAP user. Once done, try to access the extended site using the LDAP user that was added.
Tuesday, February 16, 2010
Orphaned sites in MOSS 2007
There has been issues related to orphaned items present in the sharepoint sites. Inorder to detect and delete the orphaned items follow the commands as mentioned below...
Detect an orphan site
To detect orphaned items, use the following syntax:
stsadm -o databaserepair -url http://sharepointsite/ -databasename [name of DB where orphaned site is present]
Delete an orphan site
To delete orphaned items, use the following syntax:
stsadm -o databaserepair -url http://sharepointsite/ -databasename [name of DB where orphaned site is present] -deletecorruption
For more reference on this http://technet.microsoft.com/en-us/library/cc263282.aspx
Hope this helps someone...
Detect an orphan site
To detect orphaned items, use the following syntax:
stsadm -o databaserepair -url http://sharepointsite/ -databasename [name of DB where orphaned site is present]
Delete an orphan site
To delete orphaned items, use the following syntax:
stsadm -o databaserepair -url http://sharepointsite/
For more reference on this http://technet.microsoft.com/en-us/library/cc263282.aspx
Hope this helps someone...
Friday, January 22, 2010
Deleting a WebPart from a Page using PowerShell
I had come across a requirement where I had to automate the deletion of the webpart from the page and not from Webpart Gallery. I have written a PowerShell script that takes care of the above requirement. WebPart.txt file contains the name of the webparts that needs to be deleted from the page.
-------------------
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$url = "http://myserver"
$WebPageUrl = "Pages/Default.aspx"
$wpNames = Get-Content "c:\Powershell\webparts.txt"
$SPSite = New-Object Microsoft.Sharepoint.SPSite($url)
$SPWeb = $SPSite.OpenWeb()
$SPWeb.Title
foreach ($wpName in $wpNames)
{
$SPWebPart = $SPWeb.GetWebPartCollection($WebPageUrl,
[Microsoft.SharePoint.WebPartPages.Storage]::Shared)
$SPWebPart | select Title
$count = $SPWebPart.Count
for ($k = 0; $k -lt $count; $k++)
{
$wp = $SPWebPart[$k]
if ($wp.Title -eq $wpName)
{
$SPWeb = $SPSite.OpenWeb()
$pubweb = [Microsoft.Sharepoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
$pubweb
$d = $pubweb.GetPublishingPages()
$SPPage = $d.get_Item($WebPageUrl)
$Page = $SPPage.ListItem.File
if ($Page.Level -eq [Microsoft.SharePoint.SPFileLevel]::Checkout)
{
$SPWeb.CurrentUser.LoginName
$Page.UndoCheckOut()
$Page.CheckOut()
$SPWebPart = $SPWeb.GetWebPartCollection($WebPageUrl,[Microsoft.SharePoint.WebPartPages.Storage]::Shared)
$SPWebPart.Delete($wp.StorageKey)
$SPWeb.Update()
$SPPage.CheckIn("Checked in")
$Page.Publish("Published")
$SPWeb.Update()
Write-Host " $wpName Deleted"
}
else
{
$SPPage.CheckOut()
$SPWebPart = $SPWeb.GetWebPartCollection ($WebPageUrl,Microsoft.SharePoint.WebPartPages.Storage]::Shared)
$c = $wp.StorageKey
$c
$SPWebPart.Delete($c)
$SPWeb.Update()
$SPPage.CheckIn("Checked in")
$Page.Publish("Published")
$SPWeb.Update()
Write-Host "$wpName Deleted and Checked in"
}
}
else
{
Write-Host " $wpName not found"
}
}
}
$Page.Publish("Published")
$SPWeb.Update()
-------------------
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$url = "http://myserver"
$WebPageUrl = "Pages/Default.aspx"
$wpNames = Get-Content "c:\Powershell\webparts.txt"
$SPSite = New-Object Microsoft.Sharepoint.SPSite($url)
$SPWeb = $SPSite.OpenWeb()
$SPWeb.Title
foreach ($wpName in $wpNames)
{
$SPWebPart = $SPWeb.GetWebPartCollection($WebPageUrl,
[Microsoft.SharePoint.WebPartPages.Storage]::Shared)
$SPWebPart | select Title
$count = $SPWebPart.Count
for ($k = 0; $k -lt $count; $k++)
{
$wp = $SPWebPart[$k]
if ($wp.Title -eq $wpName)
{
$SPWeb = $SPSite.OpenWeb()
$pubweb = [Microsoft.Sharepoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
$pubweb
$d = $pubweb.GetPublishingPages()
$SPPage = $d.get_Item($WebPageUrl)
$Page = $SPPage.ListItem.File
if ($Page.Level -eq [Microsoft.SharePoint.SPFileLevel]::Checkout)
{
$SPWeb.CurrentUser.LoginName
$Page.UndoCheckOut()
$Page.CheckOut()
$SPWebPart = $SPWeb.GetWebPartCollection($WebPageUrl,[Microsoft.SharePoint.WebPartPages.Storage]::Shared)
$SPWebPart.Delete($wp.StorageKey)
$SPWeb.Update()
$SPPage.CheckIn("Checked in")
$Page.Publish("Published")
$SPWeb.Update()
Write-Host " $wpName Deleted"
}
else
{
$SPPage.CheckOut()
$SPWebPart = $SPWeb.GetWebPartCollection ($WebPageUrl,Microsoft.SharePoint.WebPartPages.Storage]::Shared)
$c = $wp.StorageKey
$c
$SPWebPart.Delete($c)
$SPWeb.Update()
$SPPage.CheckIn("Checked in")
$Page.Publish("Published")
$SPWeb.Update()
Write-Host "$wpName Deleted and Checked in"
}
}
else
{
Write-Host " $wpName not found"
}
}
}
$Page.Publish("Published")
$SPWeb.Update()
Deleting WebPart from a WebPart Gallery using PowerShell
Here I shall show you how to delete a webpart of a list of webparts from the WebPart Gallery of a particular Sharepoint Site. webparts.txt contains the list of webparts that needs to be deleted from the gallery. Note that the webpart name should be in the form of webpart1.webpart or webpart.dwp as in the url http://myserver/_catalogs/wp/Forms/AllItems.aspx
-------------
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$url = "http://myserver/"
$wps = Get-Content "c:\Powershell\webparts.txt"
$SPSite = New-Object Microsoft.SharePoint.SPSite($url)
foreach($wp in $wps)
{
$SPWeb = $SPSite.OpenWeb()
$WebPartGallery = $SPWeb.Lists["Web Part Gallery"]
$gall = $WebPartGallery.Items | select Name
$count = $gall.Count
$count
for ( $i =0; $i -lt $count;$i++)
{
if ($gall[$i] -match $wp)
{
Write-Host "found"
$WebPartGallery.Items.Delete($i)
$SPWeb.Update()
Write-Host "$wp deleted"
}
$SPWeb.Dispose()
}
}
-------
Hope this helps someone....
-------------
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$url = "http://myserver/"
$wps = Get-Content "c:\Powershell\webparts.txt"
$SPSite = New-Object Microsoft.SharePoint.SPSite($url)
foreach($wp in $wps)
{
$SPWeb = $SPSite.OpenWeb()
$WebPartGallery = $SPWeb.Lists["Web Part Gallery"]
$gall = $WebPartGallery.Items | select Name
$count = $gall.Count
$count
for ( $i =0; $i -lt $count;$i++)
{
if ($gall[$i] -match $wp)
{
Write-Host "found"
$WebPartGallery.Items.Delete($i)
$SPWeb.Update()
Write-Host "$wp deleted"
}
$SPWeb.Dispose()
}
}
-------
Hope this helps someone....
Subscribe to:
Posts (Atom)