用Windows PowerShell 控制管理 Microsoft Office 365
2015-06-05 17:31
531 查看
如果想要通过PowerShell控制管理Office365,首先要安装Microsoft Online Services Sign-In Assistant 7.0,链接如下
Microsoft Online Services Sign-In Assistant 32-bit
Microsoft Online Services Sign-In Assistant 64-bit
之后,安装Microsoft Online Services Module for Windows PowerShell,链接如下
Microsoft Online Services Module for Windows PowerShell 32-bit
Microsoft Online Services Module for Windows PowerShell 64-bit
如果是管理Office365对应的AD环境,用以下code进行连接:
对应的管理AD的users和groups的cmdlet的例子如下:
如果是管理Office365上面Exchanger,用以下code进行连接:
对应的管理Exchanger的users和groups的cmdlet的例子如下:
参考资料:
http://blog.crayon.no/blogs/janegil/archive/2011/05/10/administering_2D00_microsoft_2D00_office_2D00_365_2D00_using_2D00_windows_2D00_powershell.aspx
Microsoft Online Services Sign-In Assistant 32-bit
Microsoft Online Services Sign-In Assistant 64-bit
之后,安装Microsoft Online Services Module for Windows PowerShell,链接如下
Microsoft Online Services Module for Windows PowerShell 32-bit
Microsoft Online Services Module for Windows PowerShell 64-bit
如果是管理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
相关文章推荐
- shell ssh 远程机器 追加文件内容
- linux shell俄罗斯方块
- IMSHello客户端的相关信息
- 在Windows、Linux下,分别利用BAT批处理文件和Shell脚本,生成类似“20150605_111327.txt”命名的文件
- shell的if else 以及大于,小于等逻辑表达式
- 使用 shell 脚本对 Linux 系统和进程资源进行监控
- 程序间协作方式-shell out
- 二、使用find和xargs
- PowerShell实现批量收集SCVMM中虚拟机IP-续
- Linux 文件传输客户端SSH Secure Shell Client
- xftp和xshell的使用
- bash参考手册之六(Bash特性)续七
- shell脚本启动,停止java应用程序
- shell基本命令
- waf shell执行错误的解决方法
- 防止端口扫描shell脚本
- Shell 基础
- linux shell 命令
- shell复习笔记----命令与参数
- 一、文件安全与权限