【问题标题】:I want to use powershell to map a network hard disk on a remote machine我想使用powershell在远程机器上映射网络硬盘
【发布时间】:2013-06-21 10:01:14
【问题描述】:
我在想我可以做这样的事情:
psexec \\func2_web1 New-PSDrive -Name x -PSProvider FileSystem -Root
\\argento\drops - 坚持
但失败并返回此消息:
PsExec v1.98 - 远程执行进程 版权所有 (C) 2001-2010 Mark
Russinovich Sysinternals - www.sysinternals.com
PsExec 无法在 func2_web1 上启动 New-PSDrive:
我已经在 func2_web1 上启用了 PSRemoting(我可以对那台机器运行其他 psexec 命令就好了)。
有人知道如何在远程机器上映射硬盘吗?
谢谢
【问题讨论】:
标签:
powershell
remote-access
windows-server-2012
【解决方案1】:
PSExec 不是“PowerShell exec”的缩写,它是“process exec”。您不能直接从它执行 PowerShell cmdlet。要使用 PSExec 远程执行 PowerShell 命令,必须执行以下操作(未经测试,因为我没有 psexec):
psexec \\func2_web1 powershell.exe -command -nologo "New-PSDrive -Name x -PSProvider FileSystem -Root \\argento\drops -Persist"
或者,如果您想在本地 PowerShell 会话中使用远程路由:
invoke-command -computername func2_web1 -scriptblock {New-PSDrive -Name x -PSProvider FileSystem -Root \\argento\drops -Persist}
对于后者,您可能会遇到需要resolved via CredSSP 的“双跳”问题。