我需要清除远程服务器上的文件夹,然后再向其中复制新文件。Powershell通过代理调用远程
所以我的客户端脚本包含以下内容:
Invoke-Command -Computer $TargetServer -ScriptBlock { Remove-Item $ClearPath }
当我运行此我得到以下错误:
Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests
我看这件事TechNet上的,我从这个理解是如果服务器使用代理(我试图访问互联网时做的),那么我需要使用$ PSSessionOption对象。所以我改变了我的剧本,这样下首先执行:
$User = "group\tfs_service"
$Password = ConvertTo-SecureString -String "x" -AsPlainText -Force
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $Password
$PSSessionOption = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Negotiate -ProxyCredential $Credential
现在,当我运行该脚本,我得到以下错误:
Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Setting proxy information is not valid when the HTTP transport is specified. Remove the proxy information or change the transport and try the request again
谁能告诉我我要去哪里错了?