如果想要通过PowerShell控制管理Office365,首先要安装Microsoft Online Services Sign-In Assistant 7.0,链接如下

之后,安装Microsoft Online Services Module for Windows PowerShell,链接如下

如果是管理Office365对应的AD环境,用以下code进行连接:

function connectServer($adminName, $password){
write-host "connecting to outlook.office365.com..."
$O365Cred = New-Object System.Management.Automation.PSCredential($adminName,$password);
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell -Credential$O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session
Connect-MsolService -Credential $O365Cred
}

对应的管理AD的users和groups的cmdlet的例子如下:

New-MsolUser -UserPrincipalName $principalName -DisplayName $displayName -PasswordNeverExpires $true -Password $userPassword

New-MsolGroup -DisplayName $displayName -Description $description

Add-MsolGroupMember -groupObjectid $parentGroup.ObjectId -GroupMemberType "Group" -GroupMemberObjectId $childGroup.ObjectId

addChildGroup -parent $i -childOfTree $child -groupPrefix $groupPrefix -groupList $groupList

Add-MsolGroupMember -groupObjectid $group.ObjectId -GroupMemberType "User" -GroupMemberObjectId $user.ObjectId

Remove-MsolUser -objectid $ObjectId -force

Remove-MsolGroup -objectid $ObjectId -force

如果是管理Office365上面Exchanger,用以下code进行连接:

function connectServer1($adminName, $password){
write-host "connecting to ps.outlook.com..."
Import-Module MSOnline
$sessionOption = New-PSSessionOption -SkipRevocationCheck
$O365Cred = New-Object System.Management.Automation.PSCredential($adminName,$password);
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session -AllowClobber
Connect-MsolService -Credential $O365Cred
}

对应的管理Exchanger的users和groups的cmdlet的例子如下:

New-MsolUser -UserPrincipalName $principalName -DisplayName $displayName -PasswordNeverExpires $true -Password $userPassword -LicenseAssignment $licenses -UsageLocation "US" -forcechangepassword $false

New-DistributionGroup -Name $name -DisplayName $displayName

New-DistributionGroup -Name $name -DisplayName $displayName -Type security

Add-DistributionGroupMember -groupObjectid $parentGroup.ObjectId -GroupMemberType "Group" -GroupMemberObjectId $childGroup.ObjectId

addDistributionChildGroup -parent $i -childOfTree $child -groupPrefix $groupPrefix -groupList $groupList

Add-DistributionGroupMember -Identity $group.Name -Member $user.Name

Add-DistributionGroupMember -Identity $group2.Name -Member $group.Name

Remove-DistributionGroup -Identity $Name -confirm:$false

Get-DistributionGroupMember -Identity $group.name

参考资料:

http://blog.crayon.no/blogs/janegil/archive/2011/05/10/administering_2D00_microsoft_2D00_office_2D00_365_2D00_using_2D00_windows_2D00_powershell.aspx

用Windows PowerShell 控制管理 Microsoft Office 365的更多相关文章

  1. Windows 商店应用中使用 Office 365 API Tools

    本篇我们介绍一个API 工具,用于在 Windows Store App 中使用 Office 365 API. 首先来说一下本文的背景: 使用 SharePoint 做过开发的同学们应该都知道,Sh ...

  2. 使用 Windows PowerShell 来管理和开发 windowsazure.cn 账户的特别注意事项

    6月6日,微软面向中国大陆用户开放了Microsoft Azure公众预览版的申请界面.大家可以申请免费的 beta 试用,收到内附邀请码的通知邮件后只需输入激活码即可开始免费试用.具体网址为: ht ...

  3. Windows PowerShell:管理服务器

    一.概述 Cmdlets 用于服务器的管理方面主要体现在4个方面:服务.日志.进程.服务器管理器. 1.服务 •  Get-Service.查看某个服务的属性. •  New-Service.创建一个 ...

  4. 学习笔记之Microsoft Office 365

    云办公确实很方便. Office 365 登录 | Microsoft Office https://www.office.com/ Office 365 - Wikipedia https://en ...

  5. Microsoft Office 365的安装

    一.安装准备 本教程中需要用到的工具包括:最新版的Office离线包,虚拟光驱软件,离线Kms激活工具, 下载地址:百度网盘 链接: https://pan.baidu.com/s/1sQk7zE40 ...

  6. 使用windows powershell ISE管理命令窗口,并集成git命令

    写于2018-09-03(基于win10) 开启 win + s 输入 ise 操作 主要使用新建的power shell选项卡 将git集成到power shell中 安装准备 确定你的power ...

  7. 圣何塞与 Microsoft 宣布该市为超过 5,000 名市府公务员选择 Office 365、Windows Azure 和 StorSimple

    过去几个月来我们展示了极大的客户吸引力,今天我们非常高兴地宣布,我们又赢得了一位新客户,且他们利用 Microsoft 革新 IT 的方式非常有趣. 今天,我们非常高兴地告诉大家,圣何塞市选择了 Mi ...

  8. 如何使用PowerShell批量删除Office 365的用户

    概述 本文将演示如何在必要的时候(例如在测试环境),通过PowerShell脚本批量删除Office 365的用户,首先需要通过Get-MsolUser的命令(并且配合筛选条件)获取到符合条件的用户列 ...

  9. 支持国内版Office 365的PowerShell模块现已发布

    作者:陈希章 发表于2017年5月12日 上一篇文章我详细介绍了如何在PowerShell中访问到Office 365的Graph API,在文章结尾处我留了一个问题,希望有朋友可以根据那个思路,尝试 ...

随机推荐

  1. rails 常用的验证方法 validates (转)

    Agile Web Development with Rails 17.4 validation validate              在save的时候激活validate_on_create  ...

  2. php 目录函数和日期函数

    continue . break . exit目录函数opendir(); 打开一个文件夹is_file 只判断文件是否存在: file_exists 判断文件是否存在或者是目录是否存在: is_di ...

  3. iOS保存cookie的方法

    SURLRequest*request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/ ...

  4. 静态方法中的this

    1using System; 2using System.Web.Script.Serialization; 3 4namespace Demo 5{ 6    /**//// <summary ...

  5. sql 日期格式输出 - 转

    SELECT CONVERT(varchar(100), GETDATE(), 0) 05 9 2011 9:12AM SELECT CONVERT(varchar(100), GETDATE(), ...

  6. AC中保存数据与查询数据

    //保存数据 hui.ajax(function (ret, err) { }, url, {values: {t:"test",m:"Search",c:&q ...

  7. delphi里动态创建AlphaControls实现换肤

    AlphaControls是一套Delphi下的优秀的皮肤vcl控件.几年前,一般用得比较多的是vclskin,使用很方便,可惜这套2010年已经停止维护了.后来就看到更多的人开始推崇AlphaCon ...

  8. AXUre

    [ Javascript ] 一.javascript能用来干什么? 1.数据的验证. 2.对动态这本写到网页当中. 3.可以对事件做出响应. 4.可以读写html 中的内室. 5.可以检测浏览器 6 ...

  9. linux通过端口号查找程序执行路径

    第一种: 查看ssh服务 [root@localhost shell]# netstat -anlp | grep :22tcp        0      0 0.0.0.0:22          ...

  10. “-webkit-appearance: none”按钮样式作用!

    -webkit-appearance: none,可以去除浏览器默认样式.