【发布时间】:2022-08-16 02:43:03
【问题描述】:
该计划已成功运行 4 年多。就在最近(2022 年 8 月 4 日),该程序的 pscommand 版本出现故障。我们正试图弄清楚发生了什么变化。
我们收到错误“连接到远程服务器 outlook.office365.com 失败,并显示以下错误消息:访问被拒绝。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。\”仅在处理 pssession / PSCommands 时。
代码:
public Collection<PSObject> runPSCommand(PSCommand _command, string _commandName, PSCommand _secondCommand = null)
{
PSCredential credential = new PSCredential(this.emailLogin, this.emailPass);
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri(this.WSManConnectionURI), this.MSSchema, credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
try
{
using (Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo))
{
PowerShell powershell = PowerShell.Create();
PSCommand remoteSigned = new PSCommand();
runspace.Open();
powershell.Runspace = runspace;
wsmanconnectionURI:https://outlook.office365.com/PowerShell-LiveID
MSSchema:http://schemas.microsoft.com/powershell/Microsoft.Exchange
在 runspace.Open() 处失败。
我们在这个程序上运行了多种不同类型的命令(Connect-ExchangeOnline、Connect-AzureAD、Connect-MSOLService),它们都在工作,只是运行失败的 PSCommands。
也尝试使用powershell,但也失败了:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Authentication Basic -AllowRedirection -Credential Get-Credential
出现错误:\"New-PSSession:[outlook.office365.com] 连接到远程服务器 outlook.office365.com 失败,并显示以下错误消息:访问被拒绝。 有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。\"
同样,这已经工作了多年,只是开始失败。我们检查了密码,检查了登录名,尝试了多个用户。
感谢您提供任何帮助。
-
这个问题超出了我的技能和经验,但我觉得有趣的是,根据this,版本 2207 于 8 月 3 日发布,而您在 8 月 4 日发现了您的问题。不幸的是,我没有看到任何引起我注意的更改,除非它发生在“已解决的问题”部分中,其中修复一个错误可能会产生另一个错误。
标签: c# powershell office365