Showing posts with label Script. Show all posts
Showing posts with label Script. Show all posts

Friday, October 17, 2008

SharePoint 403 Forbidden Error

During recent migrations we used the database migration method to move SPS 2003 Sites into a MOSS 2007 Farm. The basic process went like this;

  • (SPS 2003 Farm)
  • Prescan
  • Set DB's to read-only
  • Backup DB's
  • Move DB's to MOSS 2007
  • (MOSS 2007 Farm)
  • Restore DB's
  • Attach DB's

Now view your Sites and all works fine right? Not so much, how about a "403 Forbidden" error. Thats always nice! On the SPS 2003 side the sites had been "locked." This can be done through SPSSiteManager.exe or the Central Administration. Either way they were locked.

Once on the MOSS 2007 side all we had to do was "unlock" the sites. The command has changed a little bit and there were a ton of sites, so we opted to script the command that looked something like this;

Here's what I did:

The actual command is;
stsadm.exe -o setsitelock -url -lock

@echoCd\Cd “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN”stsadm.exe -o setsitelock -url http://sharepoint/sites/sitename -lock none
Repeat for Site #2
Repeat for Site #3
etc... etc...
@echo off
pause
exit

-Brian Grabowski

Wednesday, August 13, 2008

The search request was unable to connect to the Search Service

If Search was functioning fine yesterday, but seems to have taken a crap on you today you might want to try these quick and easy fixes followed by some maintenance on Service Accounts and their Logins.

Here's what I did:

Restart these services:

Indexing Service
Office SharePoint Server Search
Windows SharePoint Services Search

After this do a quick IISReset and test the search functionality.

Or heres a quick script to restart all of the services and perform an IISReset for you.

net stop "Indexing Service" && net start "Indexing Service"
net stop "Office SharePoint Server Search" && net start "Office SharePoint Server Search"
net stop "Windows SharePoint Services Search" && net start "Windows SharePoint Services Search"

iisreset \\servername /noforce
iisreset \\servername /status
pause


If this worked for you then you might want to check the Service Accounts that you have tied to these services. They stopped or quit working for a reason. Investigate your Search and Query Server's Event Viewer and see what happened.

-Brian Grabowski

Tuesday, August 5, 2008

STSADM, Site Template Codes, and Scripted Site Creation

If ever you've wanted to create Sites from the command line and quit halfway through because you had no clue what the Templates were called or named, you can finally press enter and watch impatiently for the cursor to blink down and say success. Keep in mind these are only the inherent MOSS 2007 Templates and not anything custom that you've thrown in there.

Here's the list:

WSS Templates

Team Site: STS#0
Blank Site: STS#1
Document Workspace: STS#2
Wiki Site: WIKI#0
Blog Site: BLOG#0
Basic Meeting Workspace: MPS#0
Blank Meeting Workspace: MPS#1
Decision Meeting Workspace: MPS#2
Social Meeting Workspace: MPS#3
Multiple Meeting Workspace: MPS#4

MOSS Templates

Document Center: BDR#0
Site Directory: SPSSITE#0
Report Center: SPSREPORTCENTER#0
Search Center with Tabs: SRCHCEN#0
My Site Host: SPSMSITEHOST#0
Search Center: SRCHCENTERLITE#0
Personalisation Site: SPSMSITE#0
Collaboration Portal: SPSPORTAL#0
Publishing Portal: BLANKINTERNETCONTAINER#0
Publishing Site: CMSPUBLISHING#0
Publishing Site with Workflow: BLANKINTERNET#2
News Site: SPSNHOME#0

All you need is the title and the code.

Example;

-sitetemplate STS#0

Also, here is a little code snippet in a batch file that will ask the correct questions, input the data, and create a Site Collection for you without having to go through CA. (Just edit the code to match your configuration.)

@ECHO off
cls
:start
ECHO.
ECHO Please Enter the following information:
set/p url=Complete the Site Url you wish to create. http://mysharepointsite/sites/
set/p owneremail=Enter the Owner's Email address.
set/p ownerlogin=Enter the Owner's Account Name.
set/p sitetemplate=Enter the SiteTemplate Code you wish to use.
set/p title=Enter the Title of the Site.
ECHO 1. Would you like to create the Site Collection?
set choice=
set /p choice=[Y/N] if '%choice%'=='Y' goto CreateSite
if '%choice%'=='N' goto start
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:CreateSite
stsadm.exe -o createsite -url http://mysharepointsite/sites/%url% -owneremail %owneremail% -ownerlogin %ownerlogin% -sitetemplate %sitetemplate% -title %title%
goto end
:end
pause



-Brian Grabowski