【发布时间】:2019-10-25 17:17:55
【问题描述】:
我想断开连接到 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。任何帮助表示赞赏
【问题讨论】:
-
$Session | Remove-PSSession工作吗?
标签: powershell powershell-3.0 powershell-4.0