Skip to content

Commit f14cf8d

Browse files
author
Anam Navied
committed
add error message for WindowsPowerShell
1 parent 3534eaa commit f14cf8d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/code/Utils.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,13 @@ public static void DeleteDirectory(string dirPath)
17111711
}
17121712
else if (ex is System.IO.IOException)
17131713
{
1714+
string psVersion = System.Management.Automation.Runspaces.Runspace.DefaultRunspace.Version.ToString();
1715+
if (ex.Message.Contains("The directory is not empty") && psVersion.StartsWith("5"))
1716+
{
1717+
// there is a known bug with WindowsPowerShell and OneDrive based module paths, where at uninstall time .NET Directory.Delete() will give 'The directory is not empty.' error
1718+
throw new Exception(string.Format("Cannot uninstall module with OneDrive based path on WindowsPowerShell due to .NET issue. Try installing and uninstalling using PowerShellCore if using OneDrive."), ex);
1719+
}
1720+
17141721
throw new Exception(string.Format("Access denied to path while deleting path {0}", dirPath), ex);
17151722
}
17161723
else

0 commit comments

Comments
 (0)