如果想要通过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. 使用CSS3动画模拟实现小球自由落体效果

    使用纯CSS代码模拟实现小球自由落体效果: html代码如下: <div id="ballDiv"> <div id="ball">&l ...

  2. Longest Substring Without Repeating Characters(Difficulty: Medium)

    题目: Given a string, find the length of the longest substring without repeating characters. Examples: ...

  3. Android 完整开源应用,完整开源项目

    (Antox)聊天的  (new)   (OpenKeychain)OpenPGP在android上的实现  (new)   (Flock)提供同步服务   (OpenFlappyBird)曾经火爆的 ...

  4. 移动混合开发之文件管理Final之总结

    从昨天开始:2016年7月日,早晨用时1+2个小时左右,最开始还怀疑自己能否解决,但是最终还是自己解决, 所以下次遇到问题,最好还是尽量尝试自己解决. 1.css在设计的时候,一定要把父元素的长宽高指 ...

  5. 涵涵和爸爸习惯养成进度表(三)(June 25 - )

    规则说明 23天内,没有哭脸,不超过三个无表情脸,可以给一个奖励(动画书等) 涵涵违反规则,在爸爸和妈妈都同意的情况下,可以给无表情脸 爸爸违反规则,在妈妈和涵涵都同意的情况下,可以给无表情脸 获奖记 ...

  6. LINUX二十个基础命令

    LINUX二十个基础命令 一. useradd命令 1.命令格式: useradd 选项 用户名 2.命令功能: 添加新的用户账号 3.常用参数: -c comment 指定一段注释性描述.-d 目录 ...

  7. VS2010,Qt插件安装使用

    用了几次的QtCreateor,不习惯. 果断换回VS 基本步骤: 1.安装VS2010 2.安装Qt Creator5 3.安装Qt插件 qt-vs-addin-1.2.2-opensource 就 ...

  8. AXUre

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

  9. 模板volist自增变量

  10. foreach循环 Java

    第一次遇到foreach循环,是在PHP的数组中,同样,在Java数组中,也遇到了foreach循环,都是用来遍历数组(集合).遍历数组,首先想到的一般都是用while,do while,for循环, ...