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

Rule request: AvoidDefaultEncoding #2079

Open
iRon7 opened this issue Mar 13, 2025 · 1 comment
Open

Rule request: AvoidDefaultEncoding #2079

iRon7 opened this issue Mar 13, 2025 · 1 comment

Comments

@iRon7
Copy link

iRon7 commented Mar 13, 2025

Apparently the default encoding -Encoding Default is removed from the cmdlet documentation that supports the -Encoding parameter. See e.g.:

Which makes sense in a way that this might cause compatibility issues when something is e.g. written (using -Encoding Default in Windows PowerShell 5.1 and read back in PowerShell 7 (e.g. after a PowerShell update migration). Yet, afaik, this isn't captured by any of the UseCompatibleCommands profiles either (probably because the default value is still accepted.

Also note:

  • that using any of the newer encoding values as Ansi and utf8NoBom in PowerShell 7 might cause an incompatibility issue with older versions of PowerShell.
  • the implementation of the -Encoding utf8 value also differs between Windows PowerShell and newer versions of PowerShell:

Therefore I think that it is wise to avoid the default and utf8 encoding (-Encoding Default and -Encoding utf8) when PSUseCompatibleCommands is enabled in the PSScriptAnalyzer settings.

@bergmeister
Copy link
Collaborator

Yes, it's probably a good time to update the profiles anyway, happy to accept contributions :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants