Powershell configure the SharePoint Environment
1. Configure 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. Configure health rules:
$ Spweb = Get-spweb-identity http: // siteurl
$ Splist = $ spweb. Lists ["Health analyzer rule definitions"]
$ Splistitem = $ splist. getitembyid (48)
$ Splistitem ["Schedule"] = "Weekly"
$ Splistitem. Update ()
3. Configure 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. Create and configure user profile SYN connection:
$ Upa = Get-spserviceapplication-name "user profile service application"
$ Syncaccountpassword = convertid-securestring "password1"-asplaintext-Force
Add-external-profileserviceapplication $ UPA-connectionforestname "contoso.com"-connectiondomain "contoso"-connectionusername "spups"-connectionpassword $ syncaccountpassword-secret "ou = SharePoint users, Dc = contoso, dc = com"
Powershell configuration of SharePoint Environment (continued)