powershell - 无法识别 Set-OrganizationConfing,即使我可以 Get-OrganizationConfig
问题描述
我正在尝试将整个组织的“重点收件箱”设置为禁用。我在网上找到了很多脚本和教程,其中大部分都指向在 PowerShell 中使用 Exchange Online Session。
例如:
- https://docs.microsoft.com/en-us/office365/admin/setup/configure-focused-inbox?view=o365-worldwide
- https://docs.microsoft.com/en-au/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
我的 PS 脚本如下:
# Set up Credential
$UserCredential = Get-Credential
# Create the Exchange Online session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
# Import the cmdlets into this session
Import-PSSession $Session -DisableNameChecking
# Get a list of the organisation's current settings
Get-OrganizationConfig
# Now set the 'Focused Inbox' option to 'off' for everyone
Set-OrganizationConfig -FocusedInboxOn $false
# Must remove the session to avoid clogging and clutter
Remove-PSSession $Session
'Get-OrganizationConfig' 命令返回当前配置的完整列表:
但是,当我执行“Set-OrganizationConfig”命令时,它会失败并显示以下消息:
Set-OrganizationConfig : The term 'Set-OrganizationConfig' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
路径已包含,请验证路径是否正确,然后重试。
我的假设是这是一个权限问题,但是,我可以看到所有组织的配置,并且缺少 cmdlet。
问题是什么?
我是:
- 以“管理员”身份运行 PS
- 使用“SharePointAdmin”管理员帐户获取凭据
解决方案
这是一个权限问题。
$Session
在您的 O365 租户中使用具有全局管理员权限的帐户创建一个帐户,您将看到'Set-...'
cmdlet 自动下载并插入到您的会话中。
推荐阅读
- excel - Excel js 加载项访问 Outlook/创建电子邮件
- php - 匹配确切的单词在php中的字符串中是否可用
- svg - 我可以在 Froala 中使用 Font-Awesome 而不更改为 svg
- binaryformatter - 有没有一种高性能的方法来替换 .NET5 中的 BinaryFormatter?
- python - 用于验证 JSON 和正确 json 的 python 脚本
- java - 是否可以根据次数停止警报管理器
- http - 如何从 ClientRequest 返回两个变量?
- c# - 输出字段值相同的记录
- php - 如何使用 id 将记录添加到数据库而不是更改它们(javascript 和 php)?
- reactjs - 在反应中实现承诺