dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

BitDefender issue

Open Hummer311 opened this issue 5 years ago • 4 comments

Report

Host used

  • [x] powershell.exe
  • [ ] ISE
  • [ ] VS Code
  • [x] pwsh.exe

Errors Received

The powershell.exe host closes without any error.

Steps to Reproduce

Get-DbaService 

Expected Behavior

Running the same command from the pwsh hosts on the same machine from the same account generates the expected output, without closing the session. For sake of brevity, I ran the command showing only some properties:

PS C:\Windows\System32> Import-Module dbatools -Version 1.0.135
PS C:\Windows\System32> Get-DbaService | Select-Object ServiceName,State

ServiceName                State
-----------                -----
SQLServerReportingServices Running
MSSQLFDLauncher            Stopped
MSSQLSERVER                Running
MSSQLServerOLAPService     Running
SQLBrowser                 Stopped
SQLSERVERAGENT             Running

PS C:\Windows\System32>

Actual Behavior

C:\WINDOWS\system32>powershell -noprofile
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\WINDOWS\system32> Import-Module dbatools -Version 1.0.135
PS C:\WINDOWS\system32> Get-DbaService | Select-Object ServiceName,State

C:\WINDOWS\system32>

Environmental information

PowerShell Version        : 5.1.19041.610
dbatools latest installed : 1.0.135
Culture of OS             : en-US

SQL Server:

SELECT @@VERSION
Microsoft SQL Server 2019 (RTM-GDR) (KB4517790) - 15.0.2070.41 (X64)   Oct 28 2019 19:56:59   Copyright (C) 2019 Microsoft Corporation  Developer Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 19042: ) (Hypervisor) 
SELECT @@LANGUAGE
us_english

Hummer311 avatar Dec 21 '20 14:12 Hummer311

Here's a clip showing the behaviour

https://user-images.githubusercontent.com/690711/102790548-97ae1380-4373-11eb-95f0-5eb70bd92ca5.mp4

Hummer311 avatar Dec 21 '20 15:12 Hummer311

Our module does not control the PowerShell session itself. We have no way of "exiting" from that process in Windows within our code.

I would look at the environmental configuration. If the process closed on an exception it should be logged in the operational log for PowerShell or the application/system log for Windows at least.

wsmelton avatar Dec 21 '20 15:12 wsmelton

HI! Thanks for your reply! And thanks for your suggestions.

With the help of one of my colleague, we used gflags.exe (one of the Debugging Tools of the Windows SDK) and it seems the issue is related to BitDefender simply terminating powershell.exe.

We configured gflags with these settings: image

We then ran the script and reproduced the issue.

Looking at the Application event log we see the following:

image

Hummer311 avatar Dec 21 '20 18:12 Hummer311

Thank you for posting. First I've heard of that effect occurring.

wsmelton avatar Dec 21 '20 19:12 wsmelton