Powershell配置SharePoint環境(續),sharepoint配置

來源:互聯網
上載者:User

Powershell配置SharePoint環境(續),sharepoint配置

                            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"






SharePointps1幹什的 可以在C#中調用powershell管理sharepoint2010

Powershell是微軟的新一代指令碼,可以理解為用來替代CMD的,微軟新版的所有軟體,包括Hyper-v,Exchange,2008R2的AD,都是可以通過Powershell管理的,Sharepoint當然也可以。
而且Powershell其實就源自C#,很多類直接就是C#改的,甚至就是C#的。
所以你的目標都是可以實現的。

PS1是powershell指令碼的尾碼,通過可以直接雙擊或在CMD中運行powershell *.PS1來運行指令碼。
不過由於有許可權控制,所以需要首先執行下面這個命令,才能使用指令碼,否則會報錯。
Set-ExecutionPolicy unrestricted

下面是C#調用Powershell指令碼的程式碼範例,網上找的。

/*

* C#調用PowerShell程式碼範例

*

* 需要引用System.Management.Automantion.dll

*/

using System;

using System.Collections.Generic;

using System.Collections.ObjectModel;

using System.Management.Automation;

using System.Management.Automation.Runspaces;

using System.Text;

namespace ConsoleApplication

{

class Program

{

static void Main(string[] args)

{

string result = RunScript("get-process");

Console.Write(result);

Console.Read();

}

/// <summary>

/// 運行指令碼資訊,返回指令碼輸出

/// </summary>

/// <param name="scriptText">需要啟動並執行指令碼</param>

/// <returns>output of the script</returns>

private static string RunScript(string scriptText)

{

// create Powershell runspace

Runspace runspace = RunspaceFactory.CreateRunspace();

// open it

runspace.Open();

// create a pipeline and feed it the script text

Pipeline pipeline = runspac......餘下全文>>
 
今天運行sharepoint產品與技術設定精靈出現錯誤

你說的sharepoint 3.0 是wss 3.0 吧
wss3.0 不用安裝sharepooint 2007 sp1.應該有一個WSS的SP1.
如果你想安裝sharepoint
還是吧wss卸掉。再安裝sharepoint 2007吧。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.