Connect to Office365

How to connect to office365spa

1. Connect to Exchange Online命令行

   

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Also  We can use command with username and passwordcode

$CNUser = "admin@consto.partner.onmschina.cn"
$CNPWord = ConvertTo-SecureString –String "password" –AsPlainText -Force
$CNCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $CNUser,$CNPWord
Import-Module MSOnline
Connect-MsolService -Credential $CNCredential
$ExchangeShell = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell-LiveID?PSVersion=2.0 -Credential $CNCredential -Authentication Basic -AllowRedirection
$importresults = Import-PSSession $ExchangeShell -AllowClobber

2. Connect to Office 365blog

Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned    #更改執行策略
$credential = Get-Credential        /#建立憑據
$credential                        #驗證憑據
 #鏈接到office365上面(首先要導入模塊,安裝登陸助手,Azure AD模塊)
 #注意要是安裝好了Azure Adconnect 的時候,先決條件會自動安裝成功
Import-Module MsOnline         #導入office365模塊
Get-Module                     #驗證是否導入模塊 ,如果返回Manifest   MSOnline                            {Add-MsolAdministrativeUnitMe… 便是導入模塊成功
Connect-MsolService -Credential $credential      #鏈接到office365上面
Get-MsolDomain                                    #獲取office365中的域

Also  We can use command with username and passwordip

$User = "admin@constos.partner.onmschina.cn"
$PWord = ConvertTo-SecureString –String "password" –AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pword
Import-Module MsOnline
Connect-MsolService -Credential $Credential

 

 

3. connct office 365 sharepoint onlineget

 

在你開始使用 Office 365 PowerShell 管理 SharePoint Online 以前,請確保安裝了 SharePoint Online Management Shell 及其先決條件而且已鏈接到 SharePoint Online。it

經過下載並運行 SharePoint Online Management Shell 安裝 SharePoint Online Management Shell。只需對每臺計算機執行一次此操做。io

若要打開 SharePoint Online Management Shell 的命令提示符,請從開始屏幕中鍵入 sharepoint,而後單擊「SharePoint Online Management Shell」。class

若要鏈接到 SharePoint Online,請填寫 $adminUPN 和 $orgName 變量的值(替換引號中的全部文本,包括 < and > 字符),而後在 SharePoint Online Management Shell 命令提示符中運行如下命令:email

 

$adminUPN="<the full email address of an Office 365 administrator account, example: jdoe@contosotoycompany.onmicrosoft.com>"
$orgName="<name of your Office 365 organization, example: contosotoycompany>"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential

https://technet.microsoft.com/library/dn568036.aspx

 

鏈接到 SharePoint Online PowerShell

在你開始使用 PowerShell 管理 SharePoint Online 以前,請確保安裝了 SharePoint Online 命令行管理程序而且已鏈接到 SharePoint Online。

經過下載並運行 SharePoint Online 命令行管理程序 安裝 SharePoint Online 命令行管理程序。只需對你正在從其中運行 SharePoint Online PowerShell 命令的每臺計算機執行一次此操做。

若要打開 SharePoint Online 命令行管理程序的命令提示符,請從開始屏幕中鍵入 sharepoint,而後單擊「SharePoint Online 命令行管理程序」。

若要鏈接到 SharePoint Online,請填寫 $adminUPN 和 $orgName 變量的值(替換引號中的全部文本,包括 < and > 字符),而後在 SharePoint Online 命令行管理程序命令提示符中運行如下命令:

 
 
$adminUPN="<the full email address of a SharePoint Online global administrator account, example: jdoe@contosotoycompany.onmicrosoft.com>"
$orgName="<name of your Office 365 organization, example: contosotoycompany>"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential

系統經過「Windows PowerShell 憑據請求」對話框提示你時,請鍵入 SharePoint Online 全局管理員賬戶的密碼。

你如今就能夠開始執行 SharePoint Online 命令。

相關文章
相關標籤/搜索