I've been working up a script to do the everything for our new production instance and I thought I'd share some of the custom functions I've made to automate some of the setup tasks.
Can't actually be done from PS apparently, you have to call stsadm.
$SmtpServer = $xmlinput.Configuration.Farm.Email.OutgoingServer
$fromEmail = $xmlinput.Configuration.Farm.Email.FromAddress
$replyToEmail = $xmlinput.Configuration.Farm.Email.ReplyToAddress
Write-Host -ForegroundColor White " - Setting Outgoing Mail..."
stsadm -o email -outsmtpserver $smtpServer -fromaddress $fromEmail, -replytoaddress $replyToEmail -codepage 65001
More low-hanging fruit, my fellow devs get antsy if they don't automatically have access to everything.
$admins = $xmlinput.Configuration.Farm.Administrators.Admin
$CAURI = "http://"+$env:COMPUTERNAME+":"+$xmlinput.Configuration.Farm.CentralAdmin.CentralAdminPort
$site = new-Object Microsoft.SharePoint.SPSite($CAURI)
$web = $site.RootWeb
$farmadministrators = $web.SiteGroups["Farm Administrators"]
foreach($AdminUser in $admins)
Write-Host -ForegroundColor White " - Adding $AdminUser to Farm Admins"
I always forget to do this and keep scratching my head later on. Adapted from:
function Open-FirewallPort($portName, $portNumber)
Write-Host -ForegroundColor White " - Opening port $portNumber for $portName"
$port = New-Object -ComObject HNetCfg.FWOpenPort
$port.Port = $portNumber
$port.Name = $portName
$port.Enabled = $true
$fwMgr = New-Object -ComObject HNetCfg.FwMgr
$profile = $fwMgr.LocalPolicy.CurrentProfile
I've also been trying to get this:
to work without much success.
I should also point out that each of these functions originate as code snippets from other folks. I'll find references for the unattributed ones later.