From f7e503e656665af66c1d08261567465f60217eeb Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Fri, 30 Oct 2020 13:32:07 -0700 Subject: [PATCH 1/2] Fix native command execution to work on SMB share --- .../namespaces/FileSystemProvider.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index be4b95dc935..8e1dc33e528 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -7842,6 +7842,8 @@ public static class InternalSymbolicLinkLinkCodeMethods private const int ERROR_NOT_A_REPARSE_POINT = 4390; + private const int ERROR_INVALID_FUNCTION = 1; + private const int FSCTL_GET_REPARSE_POINT = 0x000900A8; private const int FSCTL_SET_REPARSE_POINT = 0x000900A4; @@ -8408,7 +8410,7 @@ private static string WinInternalGetTarget(SafeFileHandle handle) if (!result) { int lastError = Marshal.GetLastWin32Error(); - if (lastError == ERROR_NOT_A_REPARSE_POINT) + if (lastError == ERROR_NOT_A_REPARSE_POINT || lastError == ERROR_INVALID_FUNCTION) return null; throw new Win32Exception(lastError); From 5cb64440591b321c83cc262b0cc5d7d2b78c86e1 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Sat, 31 Oct 2020 14:49:51 -0700 Subject: [PATCH 2/2] Fix WinInternalGetLinkType() --- .../namespaces/FileSystemProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 8e1dc33e528..0d0d8c0d50a 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -8164,7 +8164,7 @@ private static string WinInternalGetLinkType(string filePath) if (!result) { int lastError = Marshal.GetLastWin32Error(); - if (lastError == ERROR_NOT_A_REPARSE_POINT) + if (lastError == ERROR_NOT_A_REPARSE_POINT || lastError == ERROR_INVALID_FUNCTION) linkType = null; else throw new Win32Exception(lastError);