Description
Hey PowerShell extension team,
Thanks so much for the brilliant extension for PowerShell support in Visual Studio Code, i seem to be having a weird error in which the PowerShell Editor Services is trying to access one of the folders under the $RECYCLE.BIN folder in my external usb drive (Which being a system folder is denied access to pretty much everyone but the system).
I am able to reproduce this error on the latest 1.2.0 version of the PowerShell extension, please see the details below and let me know if you'd like any additional info.
Steps to reproduce
I have enabled verbose logging and reproduced the issue a few time to generate some verbose logs, please find those zipped and attached here -> logs.zip
- Open Visual Studio Code
- File -> Open Folder -> Select E:\
- Create a new document (Ctrl + N)
- Paste the following code
foreach ($domain in "testlab01.contoso.com", "testlab02.contoso.com")
{
$namingContext = $(get-adrootdse -server $domain).defaultnamingcontext
$computers = Get-ADComputer -Server $domain -Properties lastlogondate, pwdlastset, distinguishedname, operatingsystem, extensionattribute1 -ldapfilter "(&(!operatingSystem=*server*)(operatingSystem=*))"
$countdelete = 0
foreach ($Computer in $computers)
{
}
}
- Right click on $computers and select the Find All References option
If i close Visual Studio Code completely or press Ctrl + Shift + P and choose Reload Window and follow the Steps to reproduce the terminating error reoccurs.
Once the error occurs, all PowerShell extension features stop working (Intellisense, PSScriptAnalyzer etc) until i either reload the window or close and reopen Visual Studio Code.
If i continue using Visual Studio Code after the error has occured, about a minute later Visual Studio Code will show an error up the top that says
The PowerShell session has terminated due to an error, would you like to restart it? Yes No Close
Oddly enough, if i follow the Steps to reproduce and skip step 2 the issue does not occur.
Expected behavior
Peek window should come up showing a reference to "foreach ($computer in $computers)"
Actual behavior
Peek window shows up with the text "Loading" and never finishes loading
Terminal shows the following error
PowerShell Integrated Console
PS E:\>
A terminating error occurred in PowerShell Editor Services:
One or more errors occurred.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.WaitForExit()
at CallSite.Target(Closure , CallSite , Object )
One or more errors occurred.
Access to the path 'e:\$RECYCLE.BIN\S-1-5-21-1296309925-1638090579-3947801505-1001' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.AddSearchableDirsToStack(SearchData localSearchData)
at System.IO.FileSystemEnumerableIterator`1.MoveNext()
at Microsoft.PowerShell.EditorServices.Workspace.<EnumeratePSFiles>d__14.MoveNext()
at Microsoft.PowerShell.EditorServices.LanguageService.<FindReferencesOfSymbol>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<HandleReferencesRequest>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc)
at System.Threading.Tasks.Task.Execute()
Environment data
Visual Studio Code 1.12.2
Shell 1.6.6
Renderer 56.0.2924.87
Node 7.4.0
Extensions
Auto Fold 1.0.6
C# 1.10.0
C# XML Documentation Comments 0.0.15
Git History 0.2.0
PowerShell 1.2.0
VSCode Simpler icons with Angular 1.3.0
Powershell PSVersionTable output
PS E:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.1198
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1198
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS E:\>