Solved

SP 2007 - Powershell Script to modify AccessRequestEmail

Posted on 2012-04-09
3
438 Views
Last Modified: 2012-04-09
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
0
Comment
Question by:BIvsAI
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Tehzar earned 250 total points
ID: 37824389
It looks like you need to configure outgoing e-mail.  Please reference the following article to configure outgoing e-mail :

http://www.sharepointdotnet.com/2011/12/configure-emailsmtp-settings-in.html#more

hth,

ZaR
0
 

Author Closing Comment

by:BIvsAI
ID: 37824816
Crazy how it was something simple like that.  Appreciate the fresh pair of eyes.
0
 
LVL 9

Expert Comment

by:Tehzar
ID: 37824841
We've all been there, glad it worked out.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question