0

I'm having problem getting symbolic links to work in powershell as I can't create the folder on the network drive. I've tried Test-NetConnection -ComputerName crex2cloud -Port 445 I get a response but when I try to create the symbolic link with the following command; New-Item -ItemType SymbolicLink -path $pathh -Target $target it doesn't work.
$pathh variable is the source and $target is the target folder which I want to create, although each time I attempt to create a symbolic link using the above command I get this error;

New-Item : Cannot find path 'T:\csync' because it does not exist.
At line:1 char:1
+ New-Item -ItemType SymbolicLink -path $pathh -Target $target

When I try using the UNC path, first there is a pause; then this error;

New-Item : Cannot find path '\\crex2cloud\csync' because it does not exist.
At line:1 char:1
+ New-Item -ItemType SymbolicLink -path $pathh -Target $target
  • Well does the file exist? Possible duplicate of https://stackoverflow.com/questions/17813002/unable-to-access-unc-paths-in-powershell-remote-session?rq=1 – Nico Nekoru Jun 09 '20 at 04:46
  • Does this answer your question? [Unable to access UNC Paths in Powershell remote session](https://stackoverflow.com/questions/17813002/unable-to-access-unc-paths-in-powershell-remote-session) – Nico Nekoru Jun 09 '20 at 04:47

1 Answers1

0

Use Test-Path instead of Test-NetConnection

Then you can also wrap it in an if statement:

   if (Test-path '\\crex2cloud\csync') {Write-host "path found"}
    else
    {New-Item -ItemType SymbolicLink -path $pathh -Target $target}

Also double check your permissions on the share. You can use the admin share also.

"\\server\c$\whateverfolder"