You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This rule flags cmdlets that are available in a given Edition/Version of PowerShell on a given Operating System which are overwritten by a function declaration. It works by comparing function declarations against a set of whitelists which ship with PSScriptAnalyzer. They can be found at `/path/to/PSScriptAnalyzerModule/Settings`. These files are of the form, `PSEDITION-PSVERSION-OS.json` where `PSEDITION` can be either `Core` or `Desktop`, `OS` can be either `Windows`, `Linux` or `MacOS`, and `Version` is the PowerShell version.
8
+
9
+
## Configuration
10
+
11
+
To enable the rule to check if your script is compatible on PowerShell Core on Windows, put the following your settings file.
12
+
13
+
14
+
```PowerShell
15
+
@{
16
+
'Rules' = @{
17
+
'PSAvoidOverwritingBuiltInCmdlets' = @{
18
+
'PowerShellVersion' = @("core-6.1.0-windows")
19
+
}
20
+
}
21
+
}
22
+
```
23
+
24
+
### Parameters
25
+
26
+
#### PowerShellVersion
27
+
28
+
The parameter `PowerShellVersion` is a list that contain any of the following
29
+
30
+
- desktop-2.0-windows
31
+
- desktop-3.0-windows
32
+
- desktop-4.0-windows (taken from Windows Server 2012R2)
33
+
- desktop-5.1.14393.206-windows
34
+
- core-6.1.0-windows (taken from Windows 10 - 1803)
35
+
- core-6.1.0-linux (taken from Ubuntu 18.04)
36
+
- core-6.1.0-linux-arm (taken from Raspbian)
37
+
- core-6.1.0-macos
38
+
39
+
**Note**: The default value for `PowerShellVersion` is `"core-6.1.0-windows"` if PowerShell 6 or later is installed, and `"desktop-5.1.14393.206-windows"` if it is not.
40
+
41
+
Usually, patched versions of PowerShell have the same cmdlet data, therefore only settings of major and minor versions of PowerShell are supplied. One can also create a custom settings file as well with the [New-CommandDataFile.ps1](https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Utils/New-CommandDataFile.ps1) script and use it by placing the created `JSON` into the `Settings` folder of the `PSScriptAnalyzer` module installation folder, then the `PowerShellVersion` parameter is just its file name (that can also be changed if desired).
42
+
Note that the `core-6.0.2-*` files were removed in PSScriptAnalyzer 1.18 since PowerShell 6.0 reached it's end of life.
0 commit comments