Powershell O356 ExchangeOnline 登录&管理
---第一篇随笔,参考同站点前辈以及微软官方文档整理。
第一步,连接Exchange Online
安装 Exchange Online 模块。(操作系统 Win10,powershell 5)
1. 以管理员打开powershell ,键入以下命令安装PowershellGet模块:
Install-Module -Name PowerShellGet -Force
2. 安装Exchangeonline 模块
Install-Module -Name ExchangeOnlineManagement
3.加载Exchangeonline 模块
Import-Module ExchangeOnlineManagement
第二步,连接到Exchangeonline
Connect-ExchangeOnline -UserPrincipalName <UPN> [-ShowBanner:$false] [-ExchangeEnvironmentName <Value>] [-DelegatedOrganization <String>] [-PSSessionOption $ProxyOptions]
参数ExchangeEnvironmentName目前有五种类型
•Microsoft 365 or Microsoft 365 GCC: The required value is O365Default, but that's also the default value, so you don't need to use this parameter.
•Office 365 Germany: O365GermanyCloud
•Office 365 operated by 21Vianet: O365China
•Microsoft 365 GCC High: O365USGovGCCHigh
•Microsoft 365 DoD: O365USGovDoD
Example:
Connect-ExchangeOnline -UserPrincipalName navin@contoso.com
之后会弹出认证窗口输入密码,有MFA的也会需要你的短信或者Auth APP 认证。
在连接时候可能会遇到,“OAuth创建Powershell会话失败” 的问题。以下是解决方式
参考网站: https://stackoverflow.com/questions/65181149/create-powershell-session-is-failed-using-oauth
1.启用 winrm
winrm quickconfig
2.注册表为 winrm enbale Basic Auth
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client] "AllowBasic"=dword:00000001
第三, Exchange管理
简单的通过一个删除用户日历中会议的列子概述
语法:
Remove-CalendarEvents [-Identity] <MailboxIdParameter> -QueryWindowInDays <Int32> [-CancelOrganizedMeetings] [-Confirm] [-PreviewOnly] [-QueryStartDate <ExDateTime>] [-WhatIf] [<CommonParameters>]
Example:例子中删除了用户 chris@contoso.com 迄今为止以及120天以后的所有会议。
Remove-CalendarEvents -Identity chris@contoso.com -CancelOrganizedMeetings -QueryWindowInDays 120
本笔记中参考了同站CQman 的博客
https://www.cnblogs.com/CQman/p/14409468.html
微软的官方文档
https://docs.microsoft.com/en-us/powershell/module/exchange/remove-calendarevents?view=exchange-ps
本文来自博客园,作者:Abstracthinking,转载请注明原文链接:https://www.cnblogs.com/Abstracthinking/p/16658453.html