如果想要通过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. HTML5 拖动

    触发的事件有:dragstart事件.drag事件和dragend事件. 按下鼠标键并开始移动鼠标的时候,会在被拖拽的元素上触发dragstart事件.这时候光标变成”不能放”符号(圆环中有一条反斜线 ...

  2. 学习Find函数和select

    Find函数其实就类似于在excel按下Ctrl+F出现的查找功能:在某个区域中查找你要找的字符,一旦找到就定位到第一个对应的单元格.所以Find函数的返回值是个单元格,也就是个range值.举例,s ...

  3. 解决ORA-14450:试图访问已经在使用的事务处理临时表

    select * from dba_objects where object_name='TEMP_MZGL_BRSFD'; select 'alter system kill session ''' ...

  4. 上传文件swfUploadConfig.js

    /*/* * Unobstrusive swf upload widget using jQuery. *example : $(':file.uo_widget_form_input_file_sw ...

  5. UE4 Plugins插件分享:

    嘿,基佬你掉的插件! https://github.com/EverNewJoy/VictoryPlugin VictoryBPLibrary ---- 由活跃于 UE4 社区的某基佬 Rama 实现 ...

  6. 【Python】二分查找算法

    二分查找:在一段数字内,找到中间值,判断要找的值和中间值大小的比较.如果中间值大一些,则在中间值的左侧区域继续按照上述方式查找.如果中间值小一些,则在中间值的右侧区域继续按照上述方式查找.直到找到我们 ...

  7. PHP生成二维码图片

    下载二维码文件:http://files.cnblogs.com/isboy/qr_code.zip 需要加入的HTML:<img id="js_pc_qr_code_img" ...

  8. SQL Server如何编辑超过前200行的数据

    从SQL Server 2008开始,微软为了提高查询效率等原因,右键点击表时弹出菜单中默认没有"显示所有行",而以"选择前1000行"替代.这有时会为我们带来 ...

  9. css3-实现3D立方体旋转

    核心内容: 1.CSS3 中 animation.perspective 属性的熟练运用. 2.CSS3 中的变形属性 transform,在 3D 立体效果中的运用. 3.3D 立方体旋转实现原理. ...

  10. Unattend.xml应答文件制作(WISM)

    将制作好的应答文件unattend.xml拷贝到模板机sysprep目录下,然后在cmd下运行 (unattend.xml文件可自定义名称)   sysprep /generalize /oobe / ...