0
votes

I was thinking I could do something like this:

psexec \\func2_web1 New-PSDrive -Name x -PSProvider FileSystem -Root \\argento\drops -Persist

But that fails and comes back with this message:

PsExec v1.98 - Execute processes remotely Copyright (C) 2001-2010 Mark Russinovich Sysinternals - www.sysinternals.com

PsExec could not start New-PSDrive on func2_web1:

I have enabled PSRemoting on func2_web1 (and I can run other psexec commands against that machine just fine).

Does anyone know how I can map a hard disk on a remote machine?

Thanks

1

1 Answers

1
votes

PSExec is not short for "PowerShell exec", it's "process exec". You cannot execute an PowerShell cmdlet directly from it. To use PSExec to execute a PowerShell command remotely, you must do the following (untested, as I don't have psexec):

psexec \\func2_web1 powershell.exe -command -nologo "New-PSDrive -Name x -PSProvider FileSystem -Root \\argento\drops -Persist"

Or, if you want to go the remoting route from within your local PowerShell session:

invoke-command -computername func2_web1 -scriptblock {New-PSDrive -Name x -PSProvider FileSystem -Root \\argento\drops -Persist}

With the latter, you may have "double-hop" issues that need to be resolved via CredSSP.