Lembasts
Lembasts

Reputation: 113

Powershell object property names case sensitive?

I wrote a script in our test system that accessed some SCCM objects and their properties. All the property names of these objects were entered in lower case and it all worked. I then ported the script to our production environment and the script failed. What I discovered was that all the object property names had become case sensitive! So instead of $var.name, I had to use $var.Name. I could not find any option in powershell that turns property names into strict case sensitive. Anyone know of such an option? We are running Powershell V3 btw.

Upvotes: 1

Views: 2089

Answers (1)

Bluecakes
Bluecakes

Reputation: 2159

For the most part Powershell is Case Aware but not Case Sensitive.

Many exceptions however can be found in external cmdlets or functions that have been made available to Powershell such as [ADSI] and LDAP or even [Regex]

I've also noticed in my scripting that ForEach likes the properties to be in lower case but it's the only specific commands I've encountered with this preference.

It seems to be quite a weird topic as well but doing a quick search i found a few articles that were a good read

Technet Discussion

and linked with

Similar Technet Discussion

Upvotes: 3

Related Questions