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
Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.
The FileSystem and Environment providers are case-sensitive on case-sensitive file systems. Generally, but not always, that means case-insensitive for Windows systems and case-sensitive for non-Windows systems. See: about_Case-Sensitivity lacks detail in a lot of areas #12624 (comment)
[void] (New-Item-Path Temp:foo.txt -Force)
(Get-Item-Path Temp:FOO.txt).Name
# Get-Item: Cannot find path 'Temp:/FOO.txt' because it does not exist.
(Get-Item-Path Temp:F[O]*.txt).Name
# foo.txt
(Get-Item-Path Env:hOME).Name
# Get-Item: Cannot find path 'Env:/hOME' because it does not exist.
(Get-Item-Path Env:hOM[E]).Name
# HOME
Parameter set names:
DefaultParameterSetName case must be identical to ParameterSetName.
.NET methods often exhibit case-sensitive behavior by default. E.g.,
Equivalent .NET methods (without explicit opt-in) for common PowerShell operators.
E.g., Array.Contains(), String.Contains(), String.Replace(), Regex.Match(), Regex.Replace(), etc.
Reflection (member names must use the correct case).
Non-literal dictionary instantiation.
E.g., [hashtable]::new() has case-sensitive keys, whereas a hash table literal @{} has case-insensitive keys. Likewise with [ordered] @{} vs [ordered]::new() ([ordered] is only a type accelerator in PS v7+).
Explicitly calling Enum.Parse() is case-sensitive by default, whereas PowerShell typically handles enums in a case-insensitive manner.
Compare-object-ReferenceObject a -DifferenceObject A # Equal (no output)Compare-object-ReferenceObject ([char] 'a') -DifferenceObject ([char] 'A') # Different (output)
[pscustomobject] @{ Foo='Bar' }, [pscustomobject] @{ Foo='bar' } |Group-Object-Property Foo -CaseSensitive -AsHashtable
# Win PS: The objects grouped by this property cannot be expanded because there is a key duplication.# PS 7+: OK.
Areas of PowerShell which are guaranteed to be case-insensitive on all systems:
Non-dictionary member-access
Operator names
Non-ExternalScript/Application command discovery
Parameter names
Variable names/Get-Variable/Variable:
Keywords
using namespace statements
Type literals
#Requires
Comment-based help
PS provider names
PS drive names
Scope modifiers
Suggested Fix
Be explicitly clear that on systems with a case-sensitive file system, the FileSystem and Environment PS providers are case-sensitive, except with wildcard matching/globbing.
Call out areas of PowerShell which are either case-sensitive by default on all systems or are inconsistent/conditional with case handling. See details above.
Add additional examples in which case-insensitivity is guaranteed on all systems.
Perhaps document exactly how case-sensitivity is handled in all of the main serialization/deserialization formats (CSV, JSON, XML, CLIXML) and potential workarounds with problematic input.
Prerequisites
Get-Foocmdlet" instead of "Typo."Links
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_case-sensitivity
Summary
about_Case-Sensitivitylacks detail in a lot of areas.The purpose of this issue is to document areas of PowerShell which are case-sensitive by default or handle case inconsistently/conditionally.
Details
Areas of PowerShell which are either case-sensitive by default or handle case inconsistently/conditionally:
FileSystemandEnvironmentproviders are case-sensitive on case-sensitive file systems. Generally, but not always, that means case-insensitive for Windows systems and case-sensitive for non-Windows systems. See:about_Case-Sensitivitylacks detail in a lot of areas #12624 (comment)DefaultParameterSetNamecase must be identical toParameterSetName.Array.Contains(),String.Contains(),String.Replace(),Regex.Match(),Regex.Replace(), etc.[hashtable]::new()has case-sensitive keys, whereas a hash table literal@{}has case-insensitive keys. Likewise with[ordered] @{}vs[ordered]::new()([ordered]is only a type accelerator in PS v7+).Enum.Parse()is case-sensitive by default, whereas PowerShell typically handles enums in a case-insensitive manner.-Uniquecmdlets:Select-Object -UniqueandGet-Uniqueare case-sensitive by default (-CaseInsensitiveswitch added in PS v7.4).Sort-Object -Uniqueis case-insensitive by default (has always had-CaseSensitiveswitch).Compare-Object:-CaseSensitiveswitch.[char]is unexpectedly case-sensitive by default; string input is case-insensitive by default.ConvertFrom-Json -AsHashtable:-AsHashtablewas added in PS v6. In PS v7.3, a change was made to treat JSON keys as case-sensitive when this parameter is specified.Management.Automation.OrderedHashtableis emitted, which has case-sensitive keys.Group-Object:-CaseSensitiveswitch.-CaseSensitiveand-AsHashtableproduces a case-insensitive hash table. Duplicate keys result in an error.-CaseSensitiveand-AsHashtableproduces a case-sensitive hash table. No error occurs with duplicate keys.Select-String:-CaseSensitiveswitch.Get-Commandand command discovery/invocation:ExternalScriptandApplicationcommand type discovery/invocation is case-sensitive.Get-Commandwildcard matching with these types is also case-sensitive.CommandTypesare case-insensitive (functions, cmdlets, etc).-c*operators are case-sensitive.-i*operators are case-insensitive.-replace/-ireplaceis case-insensitive by default, except with named capture groups, which are case-sensitive.-splitoperator:-splitand-isplitare case-insensitive.-csplitis case-sensitive, unless theIgnoreCaseoption is specified.TabExpansion2 -inputScript ./foowill complete to./Foo.txton Linux.usingstatement:using moduleandusing assemblyare case-sensitive when a path is specified.using modulewith just a module name is case-insensitive.using namespaceis always case-insensitive.`nare case-sensitive.Areas of PowerShell which are guaranteed to be case-insensitive on all systems:
ExternalScript/Applicationcommand discoveryGet-Variable/Variable:using namespacestatements#RequiresSuggested Fix
FileSystemandEnvironmentPS providers are case-sensitive, except with wildcard matching/globbing.