Powershell配置SharePoint环境
1. 配置incoming email:
$loadasm =[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$Farm =[Microsoft.SharePoint.Administration.SPFarm]::Local
$IncomingMailService = [Microsoft.SharePoint.Administration.SPServiceCollection].GetMethod("GetValue",[String]).MakeGenericMethod([Microsoft.SharePoint.Administration.SPIncomingEmailService]).Invoke($Farm.Services,"")
$IncomingMailService.Enabled=$true
$IncomingMailService.UseAutomaticSettings=$true
$IncomingMailService.ServerDisplayAddress=“lastestSP10.DC-Chris1.com”
$IncomingMailService.ServerAddress=“lastestSP10.DC-Chris1.com”
$IncomingMailService.Update()
$Acl = (Get-Item"C:\Inetpub\mailroot\drop").GetAccessControl("Access")
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("WSS_ADMIN_WPG","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$Acl.AddAccessRule($Ar)
$Ar2 = New-Object system.security.accesscontrol.filesystemaccessrule("WSS_WPG","Read","ContainerInherit,ObjectInherit","None","Allow")
$Acl.AddAccessRule($Ar2)
Set-Acl -aclobject $Acl"C:\Inetpub\mailroot\drop"
2. 配置health 规则:
$spWeb= Get-SPWeb -Identity http://siteurl
$spList =$spWeb.Lists["Health Analyzer Rule Definitions"]
$spListItem = $spList.GetItemById(48)
$spListItem["Schedule"]= “Weekly”
$spListItem.Update()
3. 配置User Profile Synchronization setting:
$userProAssembly= [Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\MicrosoftShared\Web Server Extensions\14\ISAPI
\Microsoft.Office.Server.UserProfiles.dll")
$upa =Get-SPServiceApplication -Name "User Profile Service Application"
if($userProAssembly)
{
$bindingFlags = [Reflection.BindingFlags]"Static,GetProperty,NonPublic"
$userProType =$userProAssembly.GetType("Microsoft.Office.Server.Administration.UserProfileApplication")
$bindingFlags = "NonPublic","Instance"
$IsUpscaleILMUsed = $userProType.GetProperty("IsUpscaleILMUsed",$bindingFlags)
if($IsUpscaleILMUsed)
{
$IsUpscaleILMUsed.SetValue($upa,$true,$null)
}
$upa.Update()
}
$userProAssembly= [Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\MicrosoftShared\Web Server Extensions\14\ISAPI
\Microsoft.Office.Server.UserProfiles.dll")
$upa =Get-SPServiceApplication -Name "User Profile Service Application"
if($userProAssembly)
{
$bindingFlags = [Reflection.BindingFlags]"Static,GetProperty,NonPublic"
$userProType =$userProAssembly.GetType("Microsoft.Office.Server.Administration.UserProfileApplication")
$bindingFlags = "NonPublic","Instance"
$IsUpscaleILMUsed = $userProType.GetProperty("IsUpscaleILMUsed",$bindingFlags)
$IsUsersOnlyILMImport =$userProType.GetProperty("IsUsersOnlyILMImport",$bindingFlags)
$SkipBDImport =$userProType.GetProperty("SkipBDImport",$bindingFlags)
if($IsUpscaleILMUsed)
{
$IsUpscaleILMUsed.SetValue($upa,$false,$null)
$IsUsersOnlyILMImport.SetValue($upa,$false,$null)
$SkipBDImport.SetValue($upa,$true,$null)
}
$upa.Update()
}
4. 创建和配置User Profile Syn Connection:
$upa =Get-SPServiceApplication -Name "User Profile Service Application"
$syncAccountPassword= convertto-securestring "Password1" -asplaintext -force
Add-SPProfileSyncConnection-ProfileServiceApplication $upa -ConnectionForestName "contoso.com" -ConnectionDomain"Contoso" -ConnectionUserName "spups" -ConnectionPassword $syncAccountPassword -ConnectionSynchronizationOU"OU=SharePoint
Users,DC=contoso,DC=com"