-
Notifications
You must be signed in to change notification settings - Fork 394
A rule to warn overwriting of built-in PowerShell cmdlets #1023
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
Comments
From my now-closed issue: Summary of the new featureFollowup from PowerShell/PowerShellEditorServices#686 (review). Some users have had problems starting PSES because other modules override core cmdlets (in the above case, In user story terms:
Proposed technical implementation detailsThe rule should probably lazily cache all the cmdlet names in the following core modules:
An ideal implementation probably has a default list of modules, which can be changed or added to. The simplest way to do this is to read the module manifest or run In the case where an author wants to prevent redefining cmdlets in a module they don't have installed at analysis time, I'm not entirely sure what the correct solution is, but can't imagine the problem being insoluble. What is the latest version of PSScriptAnalyzer at the point of writing1.17.1 |
Update: I think the best solution for implementing this is: Get-Command -Module <module> Unlike |
PSSA already ships with files that contain cmdlet names (and their parameters) for PowerShell version 3, 4, 5 and 6.0.2. At the moment those files are used for the UseCompatibleCmdlets rule to warn on usage of cmdlets that are not available on different PowerShell versions. In a similar fashion you could use those cmdlet names for this new rule. Let me know if you need more details for implementing this rule. |
Summary of the new feature
See the issue we faced over in PSES:
PowerShell/PowerShellEditorServices#686
MS Dynamics CRM redefines
Set-Content
which totally broke PSES.We should have a rule that detects the overwriting/redefining of important built-in cmdlets to prevent these breaks from happening in future module development.
The text was updated successfully, but these errors were encountered: