Link to home
Start Free TrialLog in
Avatar of orbhot
orbhotFlag for United States of America

asked on

Automated way to find all instances of previous SharePoint administrator

I am the new SharePoint admin for a fairly large implementation. The previous admin is gone, but his account and email are everywhere within SharePoint. I've coverd the obvious ones like the the admin in Central Administration, local admin on the boxes and such, but is there a way to find/replace his account info with mine everywhere it exists in SharePoint? I hate to spend the time going through each of the hundreds of site collections manually.
Avatar of quihong
quihong
Flag of United States of America image

Is the previous admin still working at the company? What's your overall goal? To make sure you have the appropriate access you need and/or to assure the previous admin no longer have access?

There is no out of box way to "replace" an account with another one. However, it would be possible to script something or there are third party Administration tools that has this feature.

Avatar of orbhot

ASKER

He is gone. My goal is to replace every instance of his user name and email with mine, or a service account where approriate to that notifications and such are not going to a dead inbox (and no, I don't want the Exchange admins to fwd all his email to me... who knows what kind of junk he gets).

Any ideas how to script this replacement? I am a DBA before SharePoint admin and am decent at T-SQL... Is this data (the previous admin info) stored in the SharePoint config DB?
What notification are you referring to?

You're not going to be able to do this via SQL. Reading and writing to the SharePoint databases is not supported.

Avatar of orbhot

ASKER

Anything that is sent to the site collection admin, which the previous SP admin is set as all over the place on multiple site collections and in sites within those collections. If there is no automated way to change him to me, then I best get busy... lots of places to change.
Not sure about SP Alerts (Alert Me Feature), but here is sample code to change the Access Request Email

http://stabilissolutions.blogspot.com/2009/09/sharepoint-2007-request-access-feature.html

Use Powershell, check for his email and update it to yours.
Avatar of orbhot

ASKER

Nice find. Access requests really should go to the site collection owners, which is not the old SP admin in all cases, but with this script I can change just the ones that point to his email.
That solves one piece of the puzzle. I'll increase the point value and "accept multiple solutions" if I get another piece of the puzzle.
Whats the other piece of the puzzle? 250 points isn't much :)
ASKER CERTIFIED SOLUTION
Avatar of quihong
quihong
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of orbhot

ASKER

Hmm, that script isn't working for me. The links are broken and my script (attached) from the example on the page returns:

Missing variable name after foreach.
At E:\Scripts\ChangeRequest.ps1:2 char:9
+ foreach(S <<<< PWeb web in site.AllWebs)


SPSite site = new SPSite("http://amportal");
foreach(SPWeb web in site.AllWebs)
	{
		if (web.RequestAccessEnabled && web.RequestAccessEmail == "cmason@atlanticmarine.com)
		{
			web.RequestAccessEmail = "sharepoint@atlanticmarine.com";
		}
		web.Dispose();
	}
site.Dispose();

Open in new window

That code is generic .NET code, not Powershell.

PowerShell variables start with '$'.

I don't have the time to convert it for you. Sorry.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of orbhot

ASKER

Dang, that's a complex PS script to not really do any work, such as actually update the email... just lists it out it looks like.
I found out this CAN be done at the DB. I'll still give out some points for the effort.

"Here’s a SQL statement that will change all request email addresses. The email address is stored in the “webs” table in a field called “RequestAccessEmail”.

UPDATE Webs SET RequestAccessEmail = ‘<new email>’ WHERE RequestAccessEmail = ‘<old email>’

You need to run the query in each content database.
"
http://vettekerry.wordpress.com/2008/09/12/access-requests-mass-update/
Avatar of orbhot

ASKER

Only post stuff you KNOW works, don't waste people's time posting untested stuff you find out on the Web.
Avatar of orbhot

ASKER

Here is the REAL solution...


USE [master]
SET QUOTED_IDENTIFIER OFF
GO
DECLARE @dbname sysname --database name  
DECLARE @varSQL VARCHAR(512) --SQL statement

DECLARE db_cursor CURSOR FOR --Set up cursor to go through all MOSS content DBs (use the apprpriate prefix/suffix)
SELECT [name] 
FROM master.dbo.sysdatabases 
WHERE [name] LIKE 'MOSS_%_Content' 

OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @dbname   

WHILE @@FETCH_STATUS = 0   
BEGIN
	--SQL statement to update old admin's email with an in box that is monitored
	SET @varSQL = 'USE ' + @dbname + '; s
	UPDATE Webs 
	SET RequestAccessEmail = "newemail" 
	WHERE RequestAccessEmail = "oldemail";'
	EXEC (@varSQL)

	FETCH NEXT FROM db_cursor INTO @dbname   
END   

CLOSE db_cursor   
DEALLOCATE db_cursor 

GO

Open in new window

Yes, the script I provided was to list out the AccessRequestEmail. It would only be a couple more lines to update the email.

Thanks for providing the SQL. Reading and writing to the SQL DB isn't supported by MS, so I stay away from it, especially if its possible via the Object Model.