gpt4 book ai didi

powershell - 无法断开连接到 office365 的 powershell session

转载 作者:行者123 更新时间:2023-12-03 19:30:58 25 4
gpt4 key购买 nike

我想断开连接到 office365 的远程 powershell,稍后再连接回来。

尝试了 Disconnect-PSSession 命令,但它抛出错误。

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

.
.
.
.

Disconnect-PSSession $Session

(它重定向到 https://nam04b.ps.compliance.protection.outlook.com/powershell-liveid?PSVersion=4.0 )

我看到的输出是:

disconnect-pssession : Disconnect-PSSession operation failed for runspace Id = 613e8071-b691-4365-84dc-2d65c21ea2fa
for the following reason: The disconnection operation is not supported on the remote computer. To support
disconnecting, the remote computer must be running Windows PowerShell 3.0 or a later version of Windows PowerShell.
At line:1 char:15
+ get-pssession|disconnect-pssession
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ([PSSession]Session1:PSSession) [Disconnect-PSSession], RuntimeExcepti
on
+ FullyQualifiedErrorId : PSSessionDisconnectFailed,Microsoft.PowerShell.Commands.DisconnectPSSessionCommand

我在本地运行 Powershell 版本 4。 Get-PSSessionConfiguration 在服务器上显示 PSVersion 4。任何帮助表示赞赏

最佳答案

正如 Theo 所指出的,使用 Remove-PSSession 可以工作,因为它在低于 3 的 PowerShell 版本中受支持,而 Disconnect-PSSession 仅在PowerShell v3。因此你的错误信息。

请参阅此链接至 Disconnect-PSSession它在哪里统计:

This cmdlet is introduced in Windows PowerShell 3.0.

关于powershell - 无法断开连接到 office365 的 powershell session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56541072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com