Link to home
Start Free TrialLog in
Avatar of BIvsAI
BIvsAIFlag for United States of America

asked on

SP 2007 - Powershell Script to modify AccessRequestEmail

I found an article on here advising on how to report on AccessRequestEmail settings and have modified such code to also update (at least I hope) the email address field with a newer one but I am receiving an error.  Can anyone offer any suggestions on why the modified code may be failing and the error being received which I am also receiving.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

$logFile = "C:\scripts\SharePoint\ListAccessRequestEmail.csv"

$startime = Get-Date
"Script Starting..." + $startime | Out-File -filepath $logFile

# Create the stopwatch
[System.Diagnostics.Stopwatch] $sw;
$sw = New-Object System.Diagnostics.StopWatch
$sw.Start()

$siteCollectionURL = "http://myurlsite:80"
$theSite = New-Object Microsoft.SharePoint.SPSite($SiteCollectionURL)
$webApp = $theSite.WebApplication

foreach($site in $webApp.Sites)
{
	foreach($web in $site.AllWebs)
	{
		if ($web.RequestAccessEnabled)
		{
			$web.RequestAccessEmail = "newaddesstouse@mail.com"
            $web.Update()
            $web.Url + "`t" + $web.RequestAccessEmail | Out-File -filepath $logFile -append
		}
		else
		{
			$web.Url + "`tRequest Access Not Enabled" | Out-File -filepath $logFile -append
		}
		$web.Dispose()
	}
	$site.Dispose()
}

$sw.Stop()
$theSite.Dispose()

# Write the compact output to the screen
write-host "Time: ", $sw.Elapsed.ToString()

Open in new window


error recieved:

Exception setting "RequestAccessEmail": "This Web application is not configured to send e-mail. For assistance, contact your server administrator."
At line:23 char:9
+             $web. <<<< RequestAccessEmail = "newaddesstouse@mail.com"
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Open in new window


Appreciate any help
ASKER CERTIFIED SOLUTION
Avatar of Tehzar
Tehzar
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 BIvsAI

ASKER

Crazy how it was something simple like that.  Appreciate the fresh pair of eyes.
We've all been there, glad it worked out.