I am trying to create a shortcut in Powershell from one server to another

298 Views Asked by At
$PrivateDrive = "Sharedrivepath1"
$ScanDrive = "ScanDrivePath2"

New-Item -Itemtype SymbolicLink -Path $PrivateDrive -Name ScanDrive -Value $ScanDrive

I am trying to create a shortcut from the ScanDrive to the PrivateDrive, I have a full filepath and have access to both locations.

These both exist.

But I get the error "New-Item : Symbolic Links are not supported for the specified path"

EDIT: This is how I declare my Private and Scan Drives

$SamaccountName = ($name).Givenname + '.' + ($name.Surname)
$PrivateDrive = '\\SERVER1\private\home folders\' + $SamaccountName
$ScanDrive = "\\SERVER2\Shares_2\" + $SamaccountName
1

There are 1 best solutions below

2
On

The error message is PowerShell's, in response to the underlying CreateSymbolicLink() WinAPI function reporting error code 1 (INVALID_FUNCTION).

There are two possible causes that I'm aware of:

  • A configuration problem: R2R (Remote-to-Remote) symlink evaluation is disabled (which is true by default.

    • To query the current configuration, run the following:

      fsutil behavior get SymLinkEvaluation
      
    • To modify the configuration, you must call from an elevated (run as admin) session. The following enables R2R symlink evaluation:

      # Requires an ELEVATED session.
      fsutil behavior set SymLinkEvaluation R2R:1
      
  • (Less likely) A fundamental limitation:

    • The remote link path (the target path too?) is not exposed vie one of the following technologies, which are the ones listed as supported in the linked WinAPI help topic:
      • Server Message Block (SMB) 3.0 protocol
      • SMB 3.0 Transparent Failover (TFO)
      • Resilient File System (ReFS)