How to fix "Can not find path" error in PowerShell?


When executing a SQL script file, I have got the below error in PowerShell. I was using PowerShell v5 in Windows 10.

Short Error message:

Get-ChildItem : Can not find path 'file path here'


This issue has happened when the length of the file path is 260 characters or more. Apparently this issue is there in PowerShell version up to 5.1.

  1. Run the below command in Administrator mode to fix the issue.
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1