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 命令。