【发布时间】:2023-04-06 15:27:01
【问题描述】:
我正在尝试构建一个使用委派管理员权限的脚本。而我的工作就是这个。
$ConnectionUri = "https://ps.outlook.com/powershell-liveid?DelegatedOrg=$TenantDefaultDomainName"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $ConnectionUri -Credential $Office365Credentials -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber
这很好,连接也很好,但我的印象是,这是旧的做法,因为一些 cmdlet 根本不适用于委派。例如,我想获取用户日历的名称并尝试使用
Get-MailboxFolderStatistics -Identity $user -FolderScope Calendar
但是我在代理命令上收到一个错误,说委派用户应该为空。因此,我想尝试使用新的 cmdlet,但几乎找不到任何有关委派的信息,请参考此处:https://docs.microsoft.com/en-us/powershell/module/exchange/connect-exchangeonline?view=exchange-ps
我想出了这个语法,但它根本不起作用。
Connect-ExchangeOnline -DelegatedOrganization $TenantDefaultDomainName -Credential $MyOffice365PartnerCredentials
这是我遇到的错误。
New-ExoPSSession : One or more errors occurred.
At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.4\netFramework\ExchangeOnlineManagement.psm1:475 char
:30
+ ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-ExoPSSession], AggregateException
+ FullyQualifiedErrorId : System.AggregateException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSession
【问题讨论】:
标签: powershell