Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0402ad6
MSI installer: Add checkbox and MSI property DISABLE_TELEMETRY to opt…
bergmeister Oct 7, 2019
5ba1546
Add test cases
bergmeister Oct 7, 2019
32c8da1
Add missing closing brace
Oct 7, 2019
3236adf
Escape brackets in WiX syntax
Oct 7, 2019
320e62c
Merge branch 'master' of https://github.com/PowerShell/PowerShell int…
bergmeister May 21, 2020
e635843
Try use Environment element
bergmeister May 21, 2020
65b06b8
Merge branch 'master' of https://github.com/PowerShell/Powershell int…
bergmeister May 21, 2020
255ca75
use unique environment id
bergmeister May 21, 2020
730be8d
Register DisableTelemetry component
bergmeister May 22, 2020
98fcf23
tweak text and add tooltip
May 22, 2020
4709072
Merge branch 'master' of https://github.com/PowerShell/powershell int…
Jun 3, 2020
33ae84f
update tooltip message
Jun 3, 2020
4a77c26
Merge branch 'master' of http://github.com/powershell/powershell into…
bergmeister Jun 22, 2020
bb56c32
update tooltip
bergmeister Jun 22, 2020
56627a8
Merge branch 'master' of http://github.com/powershell/powershell into…
bergmeister Jul 21, 2020
b3bce80
Merge branch 'master' of https://github.com/PowerShell/PowerShell int…
Oct 22, 2020
4530b9c
Merge branch 'master' into disable_telemetry_option_msi
bergmeister Apr 24, 2021
e57e20a
Merge branch 'master' of https://github.com/PowerShell/PowerShell int…
bergmeister Sep 20, 2021
7caf16e
Merge branch 'master' of https://github.com/bergmeister/PowerShell in…
bergmeister Sep 14, 2022
12efbf7
Enable the installer to remember the setting
TravisEz13 Mar 6, 2023
3c2872a
Revert "Enable the installer to remember the setting"
TravisEz13 Mar 6, 2023
7a41339
Merge remote-tracking branch 'upstream/master' into disable_telemetry…
TravisEz13 Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion assets/wix/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<ComponentRef Id="SharedRegistryEntries"/>
<ComponentRef Id="SetPath"/>
<ComponentRef Id="Telemetry"/>
<ComponentRef Id="DisableTelemetry"/>
<ComponentRef Id="ExplorerContextMenu"/>
<ComponentRef Id="PowerShellFileContextMenu"/>
</Feature>
Expand Down Expand Up @@ -213,6 +214,10 @@
<RegistryValue Type="string" Value="[VersionFolder]pwsh.exe" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="DisableTelemetry" Guid="{E86F5C91-3721-4C5C-A31F-1F0A5A468573}" KeyPath="yes">
<Condition>DISABLE_TELEMETRY</Condition>
<Environment Id="PowerShellTelemetryOptout" Action="set" Name="POWERSHELL_TELEMETRY_OPTOUT" Permanent="no" System="yes" Value="1"/>
</Component>
<!-- add ourselves to %PATH% so pwsh.exe can be started from Windows PowerShell or cmd.exe -->
<Component Id="SetPath">
<Condition>ADD_PATH=1</Condition>
Expand Down Expand Up @@ -320,7 +325,8 @@
<Control Id="AddToPathCheckBox" Type="CheckBox" X="20" Y="60" Width="290" Height="17" Property="ADD_PATH" CheckBoxValue="0" Text="Add $(var.ProductName) to Path Environment Variable"/>
<Control Id="RegisterManifestCheckBox" Type="CheckBox" X="20" Y="80" Width="290" Height="17" Property="REGISTER_MANIFEST" CheckBoxValue="0" Text="Register Windows Event Logging Manifest"/>
<Control Id="EnablePSRemotingCheckBox" Type="CheckBox" X="20" Y="100" Width="290" Height="17" Property="ENABLE_PSREMOTING" CheckBoxValue="0" Text="Enable $(var.ProductName) remoting"/>
<Control Id="ContextMenuOpenPowerShell" Type="CheckBox" X="20" Y="120" Width="290" Height="17" Property="ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL" CheckBoxValue="0" Text="Add '$(var.ExplorerContextSubMenuDialogText)' context menus to Explorer"/>
<Control Id="DisableTelemetry" Type="CheckBox" X="20" Y="120" Width="290" Height="17" Property="DISABLE_TELEMETRY" CheckBoxValue="0" Text="Disable Telemetry (Reboot or Restart of processes may be required)" ToolTip="Sets environment variable POWERSHELL_TELEMETRY_OPTOUT to 1, see https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_telemetry"/>
<Control Id="ContextMenuOpenPowerShell" Type="CheckBox" X="20" Y="140" Width="290" Height="17" Property="ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL" CheckBoxValue="0" Text="Add '$(var.ExplorerContextSubMenuDialogText)' context menus to Explorer"/>
<Control Id="ContextMenuRunPowerShell" Type="CheckBox" X="20" Y="140" Width="290" Height="17" Property="ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL" CheckBoxValue="0" Text="Add '$(var.PowerShellFileContextSubMenuDialogText)' context menu for PowerShell files"/>
<Control Id="LicenseLink" Type="Hyperlink" X="20" Y="190" Width="214" Height="17">
<Text><![CDATA[<a href="https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt">The application is distributed under the MIT license.</a>]]></Text>
Expand Down
38 changes: 38 additions & 0 deletions test/packaging/windows/msi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,43 @@ Describe -Name "Windows MSI" -Fixture {
Invoke-MsiExec -Uninstall -MsiPath $msiX64Path
} | Should -Not -Throw
}

Context "Disable Telemetry" {
It "MSI should set POWERSHELL_TELEMETRY_OPTOUT env variable when MSI property DISABLE_TELEMETRY is set to 1" -Skip:(!(Test-Elevated)) {
try {
$originalValue = [System.Environment]::GetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', '0', [System.EnvironmentVariableTarget]::Machine)
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{DISABLE_TELEMETRY = 1 }
} | Should -Not -Throw
[System.Environment]::GetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', [System.EnvironmentVariableTarget]::Machine) |
Should -Be 1
}
finally {
[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', $originalValue, [System.EnvironmentVariableTarget]::Machine)
{
Invoke-MsiExec -Uninstall -MsiPath $msiX64Path
} | Should -Not -Throw
}
}

It "MSI should not change POWERSHELL_TELEMETRY_OPTOUT env variable when MSI property DISABLE_TELEMETRY not set" -Skip:(!(Test-Elevated)) {
try {
$originalValue = [System.Environment]::GetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', 'untouched', [System.EnvironmentVariableTarget]::Machine)
{
Invoke-MsiExec -Install -MsiPath $msiX64Path
} | Should -Not -Throw
[System.Environment]::GetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', [System.EnvironmentVariableTarget]::Machine) |
Should -Be 'untouched'
}
finally {
[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', $originalValue, [System.EnvironmentVariableTarget]::Machine)
{
Invoke-MsiExec -Uninstall -MsiPath $msiX64Path
} | Should -Not -Throw
}
}
}
}
}