1
$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
Fluffarmy223
  • 47
  • 1
  • 5
  • 1
    Show us exactly how you define `$PrivateDrive` and `$ScanDrive`. In PowerShell version => 6.2, the target of the symbolic link can be a relative path. Prior to PowerShell v6.2, the target **must be a fully-qualified path**. – Theo Sep 04 '21 at 09:13
  • @Theo I Added it to the bottom, I cant figure out how to lay it out like normal in comments – Fluffarmy223 Sep 05 '21 at 05:43
  • Your path for `$PrivateDrive` has a space in it You need to use quotes around it when calling the `New-Item` cmdlet. BTW. Are you sure users SamAccountNames are in the form of `GivenName.Surname` ? A SamAccountname should be 20 characters or less.. – Theo Sep 05 '21 at 10:48
  • @Theo it still gives me the same error, "New-Item : Symbolic Links are not supported for the specified path" and yes, that is the SamAccountName, thats the standard my location has set and am required to use. – Fluffarmy223 Sep 05 '21 at 11:36
  • 1
    Can you do it using mklink.exe from within a PowerShell console (run as admin)? `mklink /d "$PrivateDrive" "$ScanDrive"`. What version of PowerShell are you using? – Theo Sep 05 '21 at 13:16
  • I tried this, CMD opened up, but did nothing. @Theo – Fluffarmy223 Sep 20 '21 at 07:09

1 Answers1

0

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)
mklement0
  • 382,024
  • 64
  • 607
  • 775
  • I tried changing the R2R syslink evaluation and it didn't change anything. I know you said its Less Likely, but how can I check these? @mklement0 – Fluffarmy223 Sep 20 '21 at 07:08
  • @Fluffarmy223, unfortunately, I don't know - perhaps you can ask whoever administraters the networked drives. – mklement0 Sep 20 '21 at 17:28