Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell ignoring telemetry opt-out options, tries to call home regularly #10005

Closed
inoperable opened this issue Jun 25, 2019 · 18 comments
Closed
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered. WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@inoperable
Copy link

I've set a number of OPT-OUT (optout? OPTOUT?) options, since i'm not sure which method is the proper one - your documentation is saying different things at different locations, and the installer, the installer says otherwise, i'm not wisers. Am I suppose to set the OPT-OUT in the user 'scope'? If the OPT-OUT var is set in the 'Machine' scope - does pwsh.exe ignores it or is the Machine Scope super-seeding User scope? Docs don't mention anything at all.

Despite setting all the variants of the opt-out env variables by running snippet in pwsh 6.2.1 and 7.0.0.p1 (built-in Administrator account, Win10 Pro build 10.0.18922.1000 ) I still got repeated connection request to MS servers which I did not approved nor was I asked about it (for users who don't filter traffic they won't even know about it)

That being said, why is it trying to connect randomly for god-knows-what every few minutes? Behaviour happens on launch / exit of pwsh.exe session - 3 times during the write of this text. Privacy being the marketing word lately in MS, but no one seems to clarify what actually is being send to where and for what - just don't drag me into the discussion about the needs of telemetry because I dont need it.

req1

req2

[System.Environment]::SetEnvironmentVariable('POWERSHELL_CLI_TELEMETRY_OPTOUT',1,'User');[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT',1,'User');[System.Environment]::SetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT',1,'User');[System.Environment]::SetEnvironmentVariable('DOTNET_TELEMETRY_OPTOUT',1,'User');[System.Environment]::SetEnvironmentVariable('POWERSHELL_CLI_TELEMETRY_OPTOUT',1,'Machine');[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT',1,'Machine');[System.Environment]::SetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT',1,'Machine');[System.Environment]::SetEnvironmentVariable('DOTNET_TELEMETRY_OPTOUT',1,'Machine')

@inoperable inoperable added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Jun 25, 2019
@iSazonov
Copy link
Collaborator

@inoperable Could you create a simple dotnet core application and try to catch the commenctions? It helps us understand where root of the issue is - in .Net Core runtime or in PowerShell.

@TravisEz13 Perhaps you could help with the issue?

@iSazonov
Copy link
Collaborator

The IP addresses (13.69.65.22 and 40.114.241.141) is in the list https://docs.microsoft.com/bs-latn-ba/azure/azure-monitor/app/ip-addresses but both PowerShell and .Net Core can use applicationinsights.

@iSazonov iSazonov added the WG-Engine core PowerShell engine, interpreter, and runtime label Jun 26, 2019
@inoperable
Copy link
Author

This is all fine and dandy, but this shouldn't be the case - this makes the whole telemetry optout option just a superstitious move. How do you differentate between telemetry and appinsights?

How does it relate to the POWERSHELL_TELEMETRY_OPTOUT. I thought the whole point of the option is to make any such connections impossible - or am I missing something.

@inoperable
Copy link
Author

ENV VARIABLES below, as you can see, both are set - for user and system (DOTNET_CLI... and DOTNET... as well which can't be seen here) - all mentioned OPTOUT combinations I've found are set - so it can't be that the variable is missing.
env

@inoperable
Copy link
Author

@inoperable Could you create a simple dotnet core application and try to catch the commenctions? It helps us understand where root of the issue is - in .Net Core runtime or in PowerShell.

Thank you for your answer - I dodn't have any dotnet sdk installed (yet). I simply add those OPTOUT options by default on every test machine to reduce noise. It is clearly the AppInsights silent optin - I went through your IP list and crossreferenced some of the ip's with my logs. Might also I just missed some smallprint somewhere but I don't remember any AppInsights part during installation.

Seriously, the only consistant thing is the missuse of the word telemetry across all MS products where one should write user data collection or spyware in short. So what's next APPINSIGHTS_TELEMETRY_OPTOUT?

@iSazonov
Copy link
Collaborator

How do you differentate between telemetry and appinsights?

Microsoft.ApplicationInsights is an API for telemetry. PowerShell and Core uses the API. POWERSHELL_TELEMETRY_OPTOUT=1 disables sending a telemetry in PowerShell Core.

@TravisEz13
Copy link
Member

It looks like you did not used the wrong environment variable name. See #10005 (comment)

@TravisEz13 TravisEz13 added the Resolution-Answered The question is answered. label Jun 26, 2019
@inoperable
Copy link
Author

It looks like you did not used the wrong environment variable name. See #10005 (comment)

I don't understand entirely what you mean - as you can see in the screenshots above, I did used the right variable name, I actually used it twice.

@TravisEz13
Copy link
Member

POWERSHELL_TELEMETRY_OPTOUT must be defined before you start PowerShell.

Perhaps something other than PowerShell is sending this telemetry.

@inoperable
Copy link
Author

As you can see in the screenshots I posted - it's definitly pwsh.exe process that is initializing the connection. It's not some unknown process, nor can there be any other process - I'm quite sure about it.

UPDATE: I just run the same on a clean VM installed Windows 10 / Powershell Core installation and with the variables set BEFORE. This aside, does this mean that after first-run it Powershell ignore those variable afterwards?

The issue is not solved. I can repeat that behaviour. It seems that Powershell does indeed ignore thoses variables.

@rkeithhill
Copy link
Collaborator

Try setting DOTNET_CLI_TELEMETRY_OPTOUT to 1 as well. Doesn't matter whether you do it in a system or user environment variable. Just make sure you new pwsh.exe console registers the values correctly i.e. make sure these output 1:

$env:DOTNET_CLI_TELEMETRY_OPTOUT
$env:POWERSHELL_TELEMETRY_OPTOUT

@rkeithhill
Copy link
Collaborator

rkeithhill commented Jun 27, 2019

BTW the nice thing about open source is you can look yourself to see where the telemetry is being sent:

private static void SendTelemetry(string eventName, Dictionary<string, string> payload)
{
try
{
var enabled = !GetEnvironmentVariableAsBool(name: TelemetryOptoutEnvVar, defaultValue: false);
if (!enabled)
{
return;
}
if (_telemetryClient == null)
{
_telemetryClient = new TelemetryClient();
}
_telemetryClient.TrackEvent(eventName, payload, null);
}
catch (Exception)
{
; // Do nothing, telemetry can't be sent
}
}

The logic is a bit odd. I wish the variable on line 71 was called optOut without the negation and then the if check on line 73 wouldn't also require negation. But it does look correct.

@inoperable
Copy link
Author

inoperable commented Jun 27, 2019

C:\Users\Administrator>pwsh
PowerShell 7.0.0-preview.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Users\Administrator> [System.Environment]::GetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT')
1
PS C:\Users\Administrator> [System.Environment]::GetEnvironmentVariable('DOTNET_TELEMETRY_OPTOUT')
1
PS C:\Users\Administrator> [System.Environment]::GetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT')
1
PS C:\Users\Administrator> [System.Environment]::GetEnvironmentVariable('POWERSHELL_CLI_TELEMETRY_OPTOUT')
1

@rkeithhill Keith, thank you for pointing out the relevant function, can patch that function to be sure but still It does not make any sense - you can see that all of those variables are set in my first post - by simply running the snippet you can verify that they are set properly in Machine and User scopes, yet those are obviously either ignored or not read for some reason.

Could it have something to do with the fact of using the built-in Administrator account instead of the usual one? I would happily patch it and be over it but the build process is - complicated - at least.
Not else comes to mind (yet)

Like written before,, see my first post- I've set 8 different variables in total... and it still does send telemetry - that's why I posted here in the first place. Double checked once again. DOTNET_... shouldn't even be there since that variable is not in function you've mentioned but I've set all kind of combinations to be sure (the documentation is not really clear about it and the whole discussion here proves it)

@rkeithhill
Copy link
Collaborator

rkeithhill commented Jun 27, 2019

RE DOTNET_CLI_TELEMETRY_OPTOUT PowerShell Core runs on top of .NET Core. So that code base would have the code to disable their telemetry. That said, you're opting out of that telemetry too.

It is possible it is another MS shared library (or PowerShell module) that is sending the telemetry. PowerShell does run in a conhost.exe instance. Do you see these connections if you fire up cmd.exe? That would rule out conhost.exe (since cmd.exe also uses it). There is active development going on with conhost right now. Maybe they're looking for telemetry on usage?

@inoperable
Copy link
Author

@rkeithhill I can't find any requests from conhost.exe in the log, never seen one directly from cmd.exe either. This happens exclusiely when pwsh.exe, 6.2.1 and 7.0.0.p1 is runnig - I'm gonna run it through xdbg64 and see if I can nail it down.

@iSazonov
Copy link
Collaborator

iSazonov commented Jun 27, 2019

I still got repeated connection request to MS servers

PowerShell Core sends the telemetry only at startup. So it is not POwerSHell issue. Root cause could be in ApplicationInsights or in .Net Core, or another process.
Debugging will help you.

@TravisEz13
Copy link
Member

TravisEz13 commented Jun 27, 2019

The variable MUST be set in the environment BEFORE the process is start as it read at startup.

Again, Please use the issue template and provide a complete repro. I really don't understand what you are trying to say the problem is here. You asked as question. The question has been answered and this issue is resolved.

If you would like us to treat this like an issue, fill out the complete issue template with the full steps required to reproduce the issue.

But, if I understand you correctly, you have a feature request, which is to recognize that you don't want telemetry to be sent after the process is started. If that is the case, please use the feature request template.

@ghost
Copy link

ghost commented Jun 29, 2019

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@ghost ghost closed this as completed Jun 29, 2019
This was referenced Apr 20, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered. WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

No branches or pull requests

4 participants