我必须在同一网络中使用windows7和另一台win Windows服务器2012的机器。我在server2012机器上的windows7机器上尝试了Enter-PSsession ...
$ComputerName = "windows7-PC"
$username="administrator"
$password="password"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cr = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
$Session = New-PSSession -ComputerName $ComputerName -Credential $cr
Invoke-Command -Session $Session -ScriptBlock { echo '1' }
在做同样的事情时,我收到了错误
New-PSSession : [windows7-PC] Connecting to remote server windows7-PC failed with the following error message : Access is denied.
Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an
不为null或为空的参数,然后再次尝试该命令。
使用相同的脚本我能够执行回声1'从windows7-pc到server2012-pc,但不是从server2012-pc到windows7-pc。
答案 0 :(得分:1)