PowerShell-Native icon indicating copy to clipboard operation
PowerShell-Native copied to clipboard

Don't request write permissions for RemotePowerShellConfig.txt

Open Tadas opened this issue 9 months ago • 0 comments

PR Summary

Change remoting config file (%windir%\System32\PowerShell\7.5.0\RemotePowerShellConfig.txt) reader to use an input stream instead of an input/output stream. This means that write access is no longer needed in this system directory. image

PR Context

This should help with issues: https://github.com/MicrosoftDocs/PowerShell-Docs/issues/11682 https://github.com/PowerShell/PowerShell/issues/18741 https://github.com/PowerShell/PowerShell/issues/20180 https://github.com/PowerShell/PowerShell/issues/14274 https://github.com/PowerShell/PowerShell/issues/17367

Tip

For completeness sake, I will mention that if you change (Get-PSSessionConfiguration -Name <session_config_name>).Filename to point at the dll that is present in PowerShell's install location (e.g. "C:\Program Files\PowerShell\7\pwrshplugin.dll") it should work without write permissions, with the added benefit of always having this file auto-updated when a new version of PowerShell is installed.

Excellent write up in https://awakecoding.com/posts/enable-powershell-winrm-remoting-in-powershell-7/ shows the command to do that:

Set-Item -Path "WSMan:\localhost\Plugin\PowerShell.7\Filename" -Value $WSManPluginPath

Tadas avatar Apr 24 '25 01:04 Tadas