Thursday, May 11, 2017

Delete IISLogs

'== This is the VB script which will delete the IIS logs which are older than 60 days from each site folder and write log about number of files deleted==='

intDeletedCount = 0

'===Append log file ========= '
Const ForAppending = 8

'===Create Log File ========= '
Set ObjForLog = CreateObject("Scripting.FileSystemObject")
Set ObjLogFile = ObjForLog.OpenTextFile("G:\Scripts\IISLogsCleanUp\log.txt", ForAppending, True)


' ======== Delete IIS log files ======== '
sLogFolder = "C:\inetpub\logs\LogFiles"
DelDate = 60   'in days
Set objFSO = CreateObject("Scripting.FileSystemObject")
set colFolder = objFSO.GetFolder(sLogFolder)
For Each colSubfolder in colFolder.SubFolders
        Set objFolder = objFSO.GetFolder(colSubfolder.Path)
        Set colFiles = objFolder.Files
        For Each objFile in colFiles
                iFileAge = now-objFile.DateLastModified
                if iFileAge > (DelDate+1)  then
                        objFSO.deletefile objFile, True
intDeletedCount = intDeletedCount + 1
                end if
        Next
Next


' ====== Count number of deleted file ====== '
intDeletedCount = intDeletedCount + 1

'======= Write Log file ====================='
ObjLogFile.WriteLine (Now & " -- " & intDeletedCount-1 & " IISLog(s) deleted older than 60days.")
ObjLogFile.Close


Set ObjForLog = Nothing
Set ObjLogFile = Nothing
Set objFSO = Nothing
Set colFolder = Nothing
Set objFolder = Nothing
Set colFiles = Nothing

Sunday, April 9, 2017

Site Collection Report

Powershell to get al site collections name, url, ID, storage, SharePoint groups, all groups role, users from each group, users' email ID, primary owner, secondary owner, Created date, last modified date:

$rootSite = Get-SPSite http://test.sharepoint.com
$spWebApp = $rootSite.WebApplication

foreach($site in $spWebApp.Sites)
{
    foreach($sites in $site.RootWeb)
{

$web = $site.OpenWeb()
$groups = $web.sitegroups

foreach ($grp in $groups)
{
$groupName = $grp.name

$role = $grp.ROles




foreach ($user in $grp.users)
{
write-host $sites.title, "User " $user.UserLogin, "Group: " $groupName, $role  -foregroundcolor yellow

$sites.url + "$" + $sites.Title + "$" + $sites.ID + "$" + $Site.Usage.Storage + "$" + $groupName + "$" + $role + "$" + $user.UserLogin + "$" +  $user.Name + "$" +  $user.Email + "$" +  $Site.Owner.Name + "$" + $Site.Owner.Email + "$" + $Site.SecondaryContact.Name + "$" + $Site.SecondaryContact.Email + "$" + $sites.Created + "$" + $sites.lastitemmodifieddate  | out-file "E:\SiteCollectionreport.csv" -Append

}
}
}
$web.Dispose()
$site.Dispose()
}

Wednesday, April 5, 2017

Powershell to get all site collection site template

The below script can be used to extract the list of all site collection, its title, URL, Template, Template ID from a specific web application:


$rootSite = Get-SPSite "link of specific web application"
$spWebApp = $rootSite.WebApplication

foreach($site in $spWebApp.Sites)
{
    foreach($sites in $site.RootWeb)
    {

write-host  $sites.url , $sites.Title , $sites.WebTemplate , $sites.WebTemplateId

$sites.url + "$" + $sites.Title + "$" + $sites.WebTemplate + "$" + $sites.WebTemplateId | out-file "G:\Scripts\Outputs\SPTemplates.csv" -Append

}
}
$web.Dispose()
$site.Dispose()

Friday, September 5, 2014

VB script to start stopped app pools

This VB script will start the stopped app pool and send email to desired email address, also it will exclude the undesired apppool. It will send email only and after if a apppool was stopped and started by this script:
=========================================================================


Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
Set oAppPools = oWebAdmin.InstancesOf("ApplicationPool")
'Search in all App Pools
For Each oAppPool In oAppPools
 IF (oAppPool.name <> "Devtesting" ) Then
   IF oAppPool.GetState= 1 Then
 'wscript.echo "App Pool Started"
 
 ElseIF  oAppPool.GetState= 3 Then
   'wscript.echo "App Pool Stopped"
   ' Following command Starts App Pool
    oAppPool.Start
   temp = temp & ", " & oAppPool.Name
    END IF
END IF
Next
 IF (temp <> "") Then
  Set objMessage = CreateObject("CDO.Message")
  objMessage.Subject = "Monitoring APP POOLS on SP Farm"
  objMessage.From = "santosh.sethi@gmail.com"
  objMessage.To = "santosh.sethi@gmail.com"
   objMessage.TextBody = "Monitorinig Message, App Pool: "   & temp & " was down and automatically started."

  '==This section provides the configuration information for the remote SMTP server.
  '==Normally you will only change the server name or IP.
  objMessage.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  'Name or IP of Remote SMTP Server
  objMessage.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP server name"
  'Server port (typically 25)
  objMessage.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  objMessage.Configuration.Fields.Update
  '==End remote SMTP server configuration section==
  objMessage.Send
 END IF
set oWebAdmin = nothing
Set oAppPools = nothing
Set objMessage = nothing


**Reference link : http://msdn.microsoft.com/en-us/library/ms691445(v=vs.90).aspx

Thursday, September 4, 2014

Powershell to Start the stopped Appools at a server

#The following powershell script will start the stopped apppools, the excluded a appools can be included in place of "Devtesting". Also this script will be in sleep mode in every 300 sec
===================================================================


Import-Module WebAdministration
$logPath = "D:\AppPool\logs\iis-recycle-" + (Get-Date).ToShortDateString() -replace "/","-"
$logPath += ".txt"
#Specify the time counter over here
$TimeCounter = 300
#Run in Infinite Loop
While ($true)
{
$Date = Get-Date
Write-Output $date | Out-File -FilePath $logPath -Append
$AppPools = Get-WmiObject -Class IIsApplicationPool -Namespace "root/MicrosoftIISv2" | Select-Object -property @{N="Name";E={$name = $_.Name; $name.Split("/")[2] }}
$ApppoolsEXclude = $AppPools | where-object {$_.Name -ne "Devtesting"}
foreach($Pool in $AppPoolsExclude)
{
$PoolName = $pool.Name
        $State = Get-WebAppPoolState -Name $PoolName
        $StateValue = $State.Value
        if($StateValue -eq "Stopped")
        {
            Write-Output "Found $PoolName as $StateValue. Proceeding to start..." | Out-File -FilePath $logPath -Append
            Start-WebAppPool -Name $PoolName
            if(-not $?)
            {
                Write-Output "Encountered an error. Pls check manually." | Out-File -FilePath $logPath -Append
            }
            else
            {
                Write-Output "Started" | Out-File -FilePath $logPath -Append
            }
        }
        else
        {
        }  
    }
     
   Write-Output "Proceeding to sleep for $TimeCounter seconds." | Out-File -FilePath $logPath -Append
   Sleep $TimeCounter
}

Friday, January 31, 2014

SharePoints List BaseTemplateType

SharePoint has many Lists. Following is a list of BaseTemplateType of some of the SharePoint List that I know for a quick reference.
Notused-1
NoListTemplate0
GenericList100
DocumentLibrary101
Survey102
Links103
Announcements104
Contacts105
Events106
Tasks107
DiscussionBoard108
PictureLibrary109
DataSources110
WebTemplateCatalog111
UserInformation112
WebPartCatalog113
ListTemplateCatalog114
XMLForm115
MasterPageCatalog116
NoCodeWorkflows117
WorkflowProcess118
WebPageLibrary119
CustomGrid120
SolutionCatalog121
NoCodePublic122
ThemeCatalog123
DesignCatalog124
AppDataCatalog125
DataConnectionLibrary130
WorkflowHistory140
GanttTasks150
HelpLibrary151
AccessRequest160
TasksWithTimelineAndHierarchy171
MaintenanceLogs175
Meetings200
Agenda201
MeetingUser202
Decision204
MeetingObjective207
TextBox210
ThingsToBring211
HomePageLibrary212
Posts301
Comments302
Categories303
Facility402
Whereabouts403
CallTrack404
Circulation405
Timecard420
Holidays421
IMEDic499
Microfeed544
ExternalList600
MySiteDocumentLibrary700
PublishingPageLibrary850
PublishingImageLibrary851
IssueTracking1100
AdminTasks1200
HealthRules1220
HealthReports1221
DeveloperSiteDraftApps1230
PersonalDocumentLibrary2002
PrivateDocumentLibrary2003

Monday, January 20, 2014

"About me" texts are bunched in user profile

Issue:
"About Me" texts are bunched in users' profile of SharePoint 2010

Workaround:
Copy the content of "About Me" and paste it in text file==> format it(remove spaces if any) ==> paste it back in "About Me" section of that user

Thursday, January 16, 2014

Search webparts in Search pages- SharePoint 2010

Search Webparts used in Search Page
Search paging:

 It display links for navigating pages containing search results. user can configure "Max Pages links before current", "Max Page links after current", " Previous link text label", "Previous link image URL", "Image URL for previous link in right-to-left languages",

Search Core Results:
 It shows the results, metadata and URLs. It includes description of results also known as snippet. Results layout can be modified by using its XSLT. The look and feel view and options can be modified through this webparts settings.
In this webpart settings we have location option with in it, we can Local search results or Internet search results or Local people search results etc.
We can increase "Results per page". Characters in summary", Characters  in URL, "Results can be sorted with relevance or modified date", "Remote duplicate results", "Ignore Noise Words", "Query lanugage can be changed", "Show More results link", etc.

Top federated results:
The Top Federated Results Web Part settings are used to execute and display search results from different locations/zone like intranet, local, FAST etc. They contain the same search settings as the Search Core Results Web Part with the exception of the Location properties(Here we can add more than one location to aggregate results from more than one location). A notable advantage of this Web Part is the option to aggregate results from several locations/zone like intranet, local, FAST etc. In this section, we will look at the following search-related settings of the Top Federated Results: choosing a federated location and using the asynchronous Ajax options.

People matches:It is very much similar to Search core webpart except in "location" dropn down it have default value as Local People search results, this settings/option can be view through it webpart settings.

Related queries:It provides a list of link to queries similar to keywords or phrases(used in best bets) entered in the search box. Searched term/text will be added as suggestion if it is used more than 6 times. Timer job is doing this process.

Search Action links:
It shows search action links on search page. It allows users to click on hyperlinks in the results set such as RSS, Alert, Relevance, Modified date, Search from windows, Alert me, allow users to display language picker.
It contains very similar settings as compared to search core except RSS, Alert, Relevance, Modified date, Search from windows, Alert me, allow users to display language picker. Admin can select to display it in search page accroding to its requirement.

Search statistics:It displays search statistics such as display mode in one or two line, display number of results on page, total number of results, search response time, latency traces(debug)

Refinement Panel:It helps users to refine its search results in search page. Also add custom refiners based on managed metadata property.
In its settings the filter category can be modified as per requirement.

Advanced search box:
It displays different parameter search options based on properties and combination of words. It also helps to create query based on including all the words,Exact phrase, Any of words, None of words. These sections of this webpart can be hide or show based on requirement.

Federated search:It returns search results from federated search locations for the provided search query. It works with all search products. Federated connectors are required to fetch results from federated location. Available connectors are News(Bing news, Business week, Google news, The register, Yahoo news), Media(Bing Image, Flickr, Yahoo Images, YouTube), Blogs(Google blog Search), Information resources(Bing, Bing local, Encyclopedia, Britannica, MSDN, Technet, Wikipedia, Yahoo!)

People refinement panel:
This webpart is similar to refinement panel webpart. This webpart renders on left hand side of the search page. It helps users to refine search results. Also add custom refines based on managed metadata property.

People search box:
It allows users to search for the peoples. Metadata property for user will be search.

Search visual best bets:Its a feature of fast search for SharePoint. It displays high confidence visual results on a search results page. Results could be also html page, picture and videos.

Search summary:
Displays suggestions for current search query. Example: If you are searching for SharePoin then below that one a suggestion will display like: Did you mean SharePoint?

Create "Best Bets" at Search page in SharePoint 2010

Keywords and Best Bets are manually configured by a site collection administrator and are a great way to target important information in your search results. When a user enters a keyword into the search box, the Best Bets are displayed as part of the search results at the top of the page marked by a yellow star.
The keywords for Best Bets are created under Top level site collection of that search page. In some architect design admins are creating search page as different site collection and some are creating as sub site.
Here are the steps to create best bets at Top level site collection of search page:
Site Action  ==> Site Settings ==> Search Keywords ==> Click on "Add Keywords" ==> Enter required information

Tuesday, January 14, 2014

Import a picture from AD for the user profile

Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation http:///my

http://support.microsoft.com/kb/2394320

Import User Profile Information of Enabled User Accounts from Active Directory to SharePoint Server 2010

To import user profile information of user accounts that are enabled in Active Directory to SharePoint Server 2010, follow these steps:
  1. On the Manage Profile Service page, click Configure Synchronization Connections.
  2. On the Synchronization Connections page, click the Active Directory connection that you want to edit, and then click Edit Connection Filters.
  3. On the Edit Connection Filters page, follow these steps:
    1. In Exclusion Filter for Users, change the Attribute drop-down to userAccountControl.
    2. In Exclusion Filter for Users, change the Operator drop-down to Bit on equals.
    3. In the Exclusion Filter for Users, select Filter box typeto 2.
    4. Click Add.
  4. Click OK.

Thursday, December 19, 2013

Worker process for App pool?

Query:
Some it is need to dragdown which which application pool/site is consuming much CPU/memory as compared to others.
Resolution:
In Windows 2008 the steps are as follows:
In Windows Server 2008 we can find worker process w3wp.exe and its associated application by following below steps
Open Windows Server 2008 -->Run command prompt as "Run as admin" --> Navigate to C:\Windows\System32\inetsrv and then run following commnads.

C:\Windows\System32\inetsrv>appcmd list wp To get list of application pool and its worker process

C:\Windows\System32\inetsrv>appcmd list sites To get list of all web sites

C:\Windows\System32\inetsrv>appcmd list appPools To get list of all application pools on IIS server.

Wednesday, December 18, 2013

"User Information List" in SharePoint 2010

"User Information List" in SharePoint 2010 is one of a list which is hidden at site collection level. One can access this hidden list by sitecollectionURL/_catalogs/users/simple.aspx SharePoint admin can consume this list in inforpath forms to retrieve users information and fetch it at inforpath form. when ever a new user is added to sharepoint site collection level not at site level, at first that user will be added to this "User Information List". So, we can consider this list as a repository of all users present in the site. /_catalog/users may show different users on different site on the same site collection We can acess this list through object model as: SPList hiddenUserList = SPContext.Current.Web.SiteUserInfoList; Note that this list contains the users which are deleted from Active Directory. Hence, whenever we delete a user from SharePoint site, its actually a soft delete and that user details still exist in this hidden list.

Wednesday, November 27, 2013

Infopath form stuck with installing or deleting in SharePoint 2010

Issue: Infopath form stuck with installing or deleting. Resolution: Restart SharePoint admin and timer services mainly on web servers

Tuesday, November 5, 2013

Hide "More Information" option from profile page

Hide "More Information" option  from profile page

1) Save following script in java file:

2) Save above java file at my site collection

3) Open person.aspx page ==> add content editor web part at the bottom of this page ==> provide the java file link to this content editor web part

Tuesday, October 29, 2013

Access denied when deploying a timer Job or activating a feature from SharePoint 2010

Issue: You might get access denied error message in event  log while activating timer job at site collection level

Cause: This is due to a new security feature implemented in SharePoint 2010. This feature explicitly blocks any modifications to the objects inheriting from SPPersistedObject in the Microsoft.SharePoint.

Resolution: Run below powershell script:
function Set-RemoteAdministratorAccessDenied-False()
{
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null

    # get content web service
    $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
    # turn off remote administration security
    $contentService.RemoteAdministratorAccessDenied = $false
   $contentService.Update()        
}

Set-RemoteAdministratorAccessDenied-False


Reference link: http://support.microsoft.com/kb/2564009

Thursday, October 24, 2013

Contribute user unable to upload specific files in SharePoint 2010

Users with contributor permissions are prevented from uploading files with the following extensions:
  • ASPX
  • MASTER
  • XAP
  • SWF
  • JAR
  • ASMX
  • ASCX
  • XSN
  • XSF

A user with contributor rights trying to upload a file with any of the above mentioned extensions will generate a modal dialog "Error: Access Denied" appears. User cannot upload the .SWF file".

Users with designer permissions can upload SWF files successfully in SharePoint 2010. More precisely, the "Add and Customize Pages" permission is required.

Users with contributor permissions could upload SWF files in WSS 3.0 or MOSS 2007.

In Sharepoint 2010, SWF is not by default in the "Blocked File Types" list of a web application but instead has been added to a list of web files considered as web sensitive. These files are listed in the WebFileExtensions property of the WebApplication. The WebFileExtensions property can be programmatically edited, for example using powershell. See WebFileExtensions for more details.

Update alerts after DB migration in SharePoint 2010

It is recommended to again set alerts if DB is attached from one web application to other.
In this scenario existing alerts will send URL of old web application

Thursday, June 20, 2013

Activate Publishing feature at all site collection through powershell

$feature = Get-SPFeature PublishingSite
$siteCollections = Get-SPSite –WebApplication http://sp2010
$siteCollections | foreach-object {
   Write-Host "Activating" $feature.DisplayName "on" $_.Url
   Enable-SPFeature $feature -Url $_.Url
}

Tuesday, April 23, 2013

Move User profile and Search services to new app server

Issue:
Need to move all the services including UPA and Search services to new app server.
Resolution:
1. Start all the services through manage services at server in CA for new app server.
2. For user profile services and sync services:
First start the user profile service at new server through manage services at server in CA, then start the user profile sync service through same option. It will redirect to new page and need to select the correct user profile application --> Credential --> ok
It will take time around 10-15 minutes to start this service including two FIM services in windows console.
3. For search service:

Start SharePoint server search from manage services at server and then enter the new search DB.
Start SharePoint Foundation search through manage services at server. It will redirect to Search service application. Click on Farm search administration --> Modify topology --> Changed teh server name for Index, Crawl and Admin options with in it

At last run the command to confirm the services and the index location:
stsadm -o spsearch -action list