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 
2

1 Answer 1

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" 
Sign up to request clarification or add additional context in comments.

Comments