401 Access Denied - Unable to Search SharePoint 2007 Sites or Access certain Web Apps in MOSS Farm

Just had an issue where MOSS SSP could not search local SharePoint sites.
When attempting to try and access the url of the sites or the SSP admin site from the local server I kept receiving logon prompts even though I was logging on with the farm account. Interestingly I could logon to the SSP and sites from other servers / client pc’s with no problems.
I initially thought someone had changed the content access (crawl) account so reset this but to no avail.
After some further investigation noticed in the security event log that I was receiving access denied.
Modifying the registry using method 2 from the article below fixed this issue:
http://support.microsoft.com/default.aspx/kb/896861

PowerShell Warmup Script for SharePoint 2007

Many of you will know that when you IISRESET a MOSS sever the first logon on to the site can take some time. SharePoint configures IIS to recycle the application pools on a nightly basis between the hours of 1 –2am (This is easily changed if these times are not convenient.

From investigation further I found a great script created by Kirk Hoffer’s – All credit goes to Kirk for this one.

You will need to download and install PowerShell on all SharePoint Server if running Windows 2003 (installed as part of Windows 2008) from here.

There's a great intro on how to run PowerShell scripts here.

From the link above basically you need to run the command in PowerShell:

Set-ExecutionPolicy RemoteSigned.

This needs to be entered only once to allow scripts to run otherwise you will receive errors when attempting to run the script.

Next step is to create a bat file to run the script after the application pool recycle nightly. Lets say 2.30.

Simply add the line:

powershell.exe c:\scripts\warmup.ps1 (assuming you placed the ps file in the scripts folder)

Create a scheduled task to run the newly created bat file and your done.

Please note that the script resets all SharePoint sites on the local server and may take time. Please test this script before adding to live environments.

Simply copy the code in the table below and name with the file extension ‘ps1’ e.g. warmup.ps1

############################################################################   



#Assumptions:   



#-Running on machine with WSS/MOSS   



#-C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN in path   



############################################################################   



 



function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)   



 



{   



 



    $wc = new-object net.webclient   



    if($cred -eq $null)   



    {   



         $cred = [System.Net.CredentialCache]::DefaultCredentials;   






     }   



     $wc.credentials = $cred;   



     return $wc.DownloadString($url);   



}   



 



#This passes in the default credentials needed. If you need specific stuff you can use something else to   



#elevate basically the permissions. Or run this task as a user that has a Policy above all the Web Applications   



#with the correct permissions   



$cred = [System.Net.CredentialCache]::DefaultCredentials;   



#$cred = new-object System.Net.NetworkCredential("username","password","machinename")   



[xml]$x=stsadm -o enumzoneurls   



foreach ($zone in $x.ZoneUrls.Collection) {   



    [xml]$sites=stsadm -o enumsites -url $zone.Default;   



    foreach ($site in $sites.Sites.Site) {   



        write-host $site.Url;   



        $html=get-webpage -url $site.Url -cred $cred;   



    }   



}