Commit 0ec5feb
authored
Fix Add-MachinePath to preserve registry value type and unexpanded variables (#819)
* Fix non-ASCII characters in OpenSSHUtils.psm1
* Fix Add-MachinePath to preserve registry value type and unexpanded variables
Refactor Add-MachinePath to avoid unintended modifications to the PATH registry value:
- Use GetValue() with DoNotExpandEnvironmentNames to preserve unexpanded environment variables (e.g., %SystemRoot%)
- Preserve original registry value type (REG_SZ vs REG_EXPAND_SZ) using GetValueKind()
- Keep original PATH entry values unchanged; normalization (expansion + backslash trimming) only used for duplicate detection
- Improve ShouldProcess implementation with proper message/prompt/description parameters for better -WhatIf/-Confirm support
- Enhance duplicate detection to compare expanded values, catching duplicates like C:\Windows\System32 vs %SystemRoot%\System32
* address comments1 parent ed76997 commit 0ec5feb
1 file changed
+25
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
832 | | - | |
| 832 | + | |
833 | 833 | | |
834 | 834 | | |
835 | 835 | | |
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
848 | 865 | | |
849 | 866 | | |
850 | 867 | | |
| |||
0 commit comments