在Powershell中使用Invoke-Command时拒绝访问

时间:2018-03-19 20:48:40

标签: powershell

当我跑步时

Invoke-Command -ComputerName NY-TRAINING -ScriptBlock { Start-Process '\\Ny-wnorales\c$\CitrixReceiver 4.10.exe' }

我收到“拒绝访问”错误消息 我甚至尝试过 enter image description here

1 个答案:

答案 0 :(得分:1)

这是一个解决方法(看起来像@EBGreen指出的双跃点问题):

$Credential = Get-Credential
Invoke-Command -ComputerName NY-TRAINING -Credential $Credential -ScriptBlock {
    $Drive = @{
        Name = 'Remote'
        PSProvider = 'FileSystem'
        Root = '\\Ny-wnorales\C$'
        Credential = $using:Credential
    }
    New-PSDrive @Drive
    Start-Process -FilePath 'Remote:\CitrixReceiver 4.10.exe' -Credential $using:Credential
}