Powershell - 运行 目标服务器上的远程会话

Powershell - Running remote session on intended server

所以我设置了一个名为 "Server01" 的远程服务器,因此我可以使用 PS2 配置。

问题是我想 运行 ISE 作为 PS2 在同一台机器上。

所以我正在尝试:

$username = "Domain\User"
$password = "Password"

$cred = new-object -typename System.Management.Automation.PSCredential -ArgumentList $username, $password

$s=new-PSsession "Server01" -authentication Credssp -credential $cred -ConfigurationName PS2

Invoke-Command -Session $s -ScriptBlock {

}
Remove-PSSession $s

在 "Server01" 时,我收到拒绝访问错误。我已确保 "Allow Delegating Fresh Credentials" 已启用并正确配置。

我正试图通过管理 Shell 避免 运行 这样做,因为我想让计划任务自动启动此脚本。

任何suggestions/ideas?

您不必使用会话配置在计划任务中调用 2.0 版的 PowerShell。

只需使用:

powershell.exe -Version 2.0

在您的任务定义中。这比尝试使用 CredSSP 远程访问本地计算机更容易、更安全。