C# 什么是PowerShell.Telemetry.ApplicationInsightsTelemetry?我可以关闭它吗?
我有一个C#测试项目,它使用C# 什么是PowerShell.Telemetry.ApplicationInsightsTelemetry?我可以关闭它吗?,c#,powershell,.net-core,.net-core-3.1,C#,Powershell,.net Core,.net Core 3.1,我有一个C#测试项目,它使用Microsoft.PowerShell.SDKNuGet包。我使用它来运行cURL命令,而我似乎无法使用HttpClient(如果您感兴趣,请详细说明) 它工作得很好,除非我使用RunImpersonated以弱用户身份运行。然后我得到以下异常: System.TypeInitializationException:“Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry”的类型初始值设定项引发异常 内
Microsoft.PowerShell.SDK
NuGet包。我使用它来运行cURL命令,而我似乎无法使用HttpClient
(如果您感兴趣,请详细说明)
它工作得很好,除非我使用RunImpersonated
以弱用户身份运行。然后我得到以下异常:
System.TypeInitializationException:“Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry”的类型初始值设定项引发异常
内部例外情况如下:
System.UnauthorizedAccessException:对路径“CreateUniqueUserId”的访问被拒绝
我不知道为什么我的cURL powershell命令需要使用Application Insights,如果可能的话,我想将其关闭
是否可以通过Powershell NuGet关闭应用程序洞察功能?从以下位置:
要选择退出此遥测,请将环境变量POWERSHELL\u telemetry\u OPTOUT
设置为true、yes或1
因此,在应用程序启动时运行此功能应该可以做到:
Environment.SetEnvironmentVariable("POWERSHELL_TELEMETRY_OPTOUT", "1");
明亮的非常感谢。