Wednesday, March 21, 2012

SharePoint 2010 February 2012 CU

Definitive Microsoft SharePoint 2010 link for all updates
http://technet.microsoft.com/en-us/sharepoint/ff800847.aspx

Pre-deployment preparations
http://technet.microsoft.com/library/ff806331(office.14).aspx

Pre-installation
Gather information about the environment

1. Locked sites

c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN>stsadm -o enumsites -url http://spdev -showlocks > E:\spdevlocksreport.txt
Review output for locked sites.

2.

Friday, January 27, 2012

Stop-SPServiceInstance - Using PowerShell to find and stop services

When a service is stuck in the starting status in Central Admin, how can you stop the service?  SharePoint Powershell of course.
First, you need to find the GUID of the service.  
Run Get-SPServiceInstance on the server with the issue.  If the name of the service is long, it will probably be cut off.  To see the full name, use powershell formatting and change the window size of the powershell prompt.  
Go to Properties > layout and change the width for buffer and window size to 120+.  
Next, enter the same command as above with the format-table -autosize option
Get-SPServiceInstance | format-table -autosize 
Second, use the GUID (ID) from the command above for the stuck service and run 
Stop-SPServiceInstance {GUID}
Wait a moment and run the first command again to verify the service has successfully stopped. 

SharePoint - script to clear the timer cache

After reading multiple blogs about standalone clear scripts made to run on one server at a time and parsing through my old batch scripts from the 90s, I put together the following script to quickly iterate through a list of servers in one environment and clear the timer job cache on all hosts.  I have only tested this on SharePoint 2010 SP1/June CU environments. So, test carefully and use at your own risk.  
NOTE:  The server names and GUID of the cache folder will need to be changed to reflect your environment for this script to work. 

REM SharePoint 2010 Timer Service Cache cleanup script
REM Curtis McDonald  
REM 11/22/2011
REM Enter the names of all WFE and APP servers below - SPACE SEPARATED
REM Enter the correct GUID for the farm
set farmservers=(spapp11 spwfe21 spwfe22)
set cachedir=c$\ProgramData\Microsoft\SharePoint\Config\edf927c3-4007-4d5f-b31d-b51fe7a3431a
REM  Stopping timer service on all hosts in farm
FOR %%F IN %farmservers% do sc \%%F stop SPTIMERV4
REM DELETE TIMER JOB CACHE
FOR %%F IN %farmservers% do copy \%%F\%cachedir%\cache.ini \%%F\c$\cache.ini.old
FOR %%F IN %farmservers% do del /Q \%%F\%cachedir%\*.*
FOR %%F IN %farmservers% do echo 1 > \%%F\%cachedir%\cache.ini
REM  Starting timer service on all hosts in farm
FOR %%F IN %farmservers% do sc \%%F start SPTIMERV4
ECHO Waiting for timer job cache rebuild process.
TIMEOUT /T 300

Get-SPTimerJob - Finding timer jobs not shown in Central Admin

Bamboo Alerts Plus Timer Jobs (and displaying wide format data from powershell)
While deploying and testing Bamboo Alerts Plus webpart for SharePoint 2010 on a multi-server farm my team recently discovered the timer jobs were not visible on the central admin server under monitoring.  But, the timer jobs were running, because alerts were being sent.  The jobs were shown on single server farms.
Through some creative efforts we discovered the timer jobs residing on the web front end servers and set about finding a simple process to report on the status of the jobs… enter powershell for SharePoint.  
Using powershell’s Get-SPTimerJob commandlet we got a listing of the timer jobs running on each server.  But, the identity name was being truncated even in the standard 80 character width of powershell when using Get-SPTimerJob |format-table -autosize.  So, I wrote up this procedure for our farm admins.
How to find the identity for the Bamboo Alert Plus Custom Timer Job:
Open SharePoint Powershell.  Select icon in top left and choose Properties.
Under Properties select Layout Tab and change Screen Buffer Size to a width of 200+.  Run this to get a listing of all timer jobs on a server. 
Get-SPTimerJob |format-table -autosize > E:\timerjobslist.txt
Search for “Bamboo Alert Plus Custom Timer Job” in the list to find the complete identity name e.g. “Bamboo Alert Plus Custom Timer Job;#374b5e86-6139-41a3-ad08-35cf4b9c0d99;#3|minutes”
Change the powershell properties width back to 80.  
Plug this identity into the following command to find the Last Run Time, Status and any error messages from the timer job:
Get-SPTimerJob -identity “Bamboo Alert Plus Custom Timer Job;#374b5e86-6139-41a3-ad08-35cf4b9c0d99;#3|minutes” | Format-Table -Property DisplayName,LastRunTime,Status,ErrorMessage 

DSQuery and DSGet - Active Directory command line queries

Recent versions of Active Directory have added some useful  command line options for finding users.  I’ll show a few options here:
dsquery and dsget are my two favorites
dsquery example:  Searching for a know user name to find out what container (ou) it exists in.
dsquery user -name username
The following output is returned:
“CN=username,OU=CORP,OU=Accounts,DC=na,DC=contoso,DC=com”
To find out more about this user account add the attribute option like this:
dsquery user -name username -attr *
Another command line tool for AD is dsget.  You can use dsget to find the groups for a particular user like this: 
dsget user  ”CN=username,OU=CORP,OU=Accounts,DC=na,DC=contoso,DC=com” -memberof