1

So I'm trying to invoke a script which creates a network drive like this:

test1.ps1

Invoke-Command -ComputerName PCname -FilePath C:\Users\pcname\Desktop\test2.ps1

test2.ps1

New-PSDrive -Name "X" -PSProvider "FileSystem" -Root "\\PCname\deploy"
cd X:/ 
ls

The drive gets made, but the Provider is not FileSystem like the test2.ps1 is telling it to do.

Name           Used (GB)     Free (GB) Provider      Root                                                                CurrentLocation PSComputerName                                
----           ---------     --------- --------      ----                                                                --------------- --------------                                
X                                                    \\PCname\deploy                                                                PCName  

As you can see, the provider seems to be empty, and when trying to access something in the X:/ drive I get "not found" issues:

Cannot find path 'X:\' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (X:\:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
    + PSComputerName        : PCname

I have also verified that I have access to that folder via share. I can contact it via \{IP}\deploy and via \{pcname}\deploy in file explorer on the PC i want to remote to.

Sfynx
  • 123
  • 6
  • By default, you cannot access network resources from a remote PowerShell session, which is known as the double-hop problem. See the linked duplicate for details. – mklement0 Jul 28 '23 at 13:56

0 Answers0