11---
22description : Describes how to use object properties in PowerShell.
33Locale : en-US
4- ms.date : 08/21/2023
4+ ms.date : 01/03/2025
55online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_properties?view=powershell-5.1&WT.mc_id=ps-gethelp
66schema : 2.0.0
77title : about_Properties
88---
99# about_Properties
1010
1111## Short description
12+
1213Describes how to use object properties in PowerShell.
1314
1415## Long description
@@ -32,7 +33,7 @@ it doesn't. A **DirectoryInfo** object, which represents a file system
3233directory, has a ** Parent** property that contains the path to the parent
3334directory.
3435
35- ### Object properties
36+ ## Object properties
3637
3738To get the properties of an object, use the ` Get-Member ` cmdlet. For example,
3839to get the properties of a ** FileInfo** object, use the ` Get-ChildItem ` cmdlet
@@ -117,7 +118,7 @@ $a.CreationTime
117118```
118119
119120``` Output
120- Saturday, June 5, 2021 7:07:00 AM
121+ Wednesday, January 24, 2024 1:18:29 AM
121122```
122123
123124You can also use the ` Select-Object ` and ` Format-List ` cmdlets to display the
@@ -144,10 +145,10 @@ Mode : -a----
144145VersionInfo : File: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
145146 InternalName: POWERSHELL
146147 OriginalFilename: PowerShell.EXE.MUI
147- FileVersion: 10.0.22000 .1 (WinBuild.160101.0800)
148+ FileVersion: 10.0.22621 .1 (WinBuild.160101.0800)
148149 FileDescription: Windows PowerShell
149- Product: Microsoft? Windows? Operating System
150- ProductVersion: 10.0.22000 .1
150+ Product: Microsoft® Windows® Operating System
151+ ProductVersion: 10.0.22621 .1
151152 Debug: False
152153 Patched: False
153154 PreRelease: False
@@ -156,8 +157,8 @@ VersionInfo : File: C:\Windows\System32\WindowsPowerShell\v1.0
156157 Language: English (United States)
157158
158159BaseName : powershell
159- Target : {C:\Windows\WinSxS\amd64_microsoft-windows-powershell-exe_31bf3856ad364e35_10.0.22000.1_none_bf599c
160- 5a06fbb6f4 \powershell.exe}
160+ Target : {C:\Windows\WinSxS\amd64_microsoft-windows-powershell-exe_31bf3856ad364e35_10.0.22621.3085_none_492
161+ e8ee57da24e0e \powershell.exe}
161162LinkType : HardLink
162163Name : powershell.exe
163164Length : 450560
@@ -167,20 +168,20 @@ IsReadOnly : False
167168Exists : True
168169FullName : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
169170Extension : .exe
170- CreationTime : 6/5/2021 7:07:00 AM
171- CreationTimeUtc : 6/5/2021 12:07:00 PM
172- LastAccessTime : 7/18/2022 12:16:17 PM
173- LastAccessTimeUtc : 7/18/2022 5:16:17 PM
174- LastWriteTime : 6/5/2021 7:07:00 AM
175- LastWriteTimeUtc : 6/5/2021 12:07:00 PM
171+ CreationTime : 1/24/2024 1:18:29 AM
172+ CreationTimeUtc : 1/24/2024 7:18:29 AM
173+ LastAccessTime : 1/3/2025 1:36:20 PM
174+ LastAccessTimeUtc : 1/3/2025 7:36:20 PM
175+ LastWriteTime : 1/24/2024 1:18:29 AM
176+ LastWriteTimeUtc : 1/24/2024 7:18:29 AM
176177Attributes : Archive
177178```
178179
179- ### Static properties
180+ ## Static properties
180181
181182You can use the static properties of .NET classes in PowerShell. Static
182- properties are properties of class, unlike standard properties, which are
183- properties of an object.
183+ properties are properties of the class, unlike standard properties, which are
184+ properties of an object instance .
184185
185186To get the static properties of a class, use the ** Static** parameter of the
186187` Get-Member ` cmdlet. For example, the following command gets the static
@@ -218,12 +219,8 @@ property of the `System.DateTime` class.
218219## Member-access enumeration
219220
220221Starting in PowerShell 3.0, when you use the member-access operator (` . ` ) to
221- access a property that doesn't exist on a list collection, PowerShell
222- automatically enumerates the items in the collection and returns the value of
223- the property on each item. For more information, see
224- [ about_Member-Access_Enumeration] ( about_Member-Access_Enumeration.md ) .
225-
226- ### Examples
222+ access a property that doesn't exist, PowerShell automatically enumerates the
223+ items in the collection and returns the value of the property for each item.
227224
228225This command returns the value of the ** DisplayName** property of every service
229226that ` Get-Service ` returns.
@@ -241,8 +238,8 @@ Application Information
241238...
242239```
243240
244- All collections have a ** Count** property that returns the number of objects in
245- the collection.
241+ Most collections in PowerShell have a ** Count** property that returns the
242+ number items in the collection.
246243
247244``` powershell
248245(Get-Service).Count
@@ -252,50 +249,40 @@ the collection.
252249176
253250```
254251
255- Starting in PowerShell 3.0, you can get the ** Count ** or ** Length ** property of
256- singleton objects that aren't collections .
252+ If a property exists on the individual objects and on the collection, only the
253+ collection's property is returned .
257254
258255``` powershell
259- (Get-Service Audiosrv).Count
260- ```
261-
262- ``` Output
263- 1
264- ```
256+ PS> $collection = @(
257+ [pscustomobject]@{Length = "foo"}
258+ [pscustomobject]@{Length = "bar"}
259+ )
265260
266- However, some objects have a ** Length** property. For example, the ** Length **
267- of a string is the number of characters in the string. The ** Count ** property
268- is the number of instances of the object.
261+ # PowerShell returns the collection's Length.
262+ $collection.Length
263+ 2
269264
270- ``` powershell
271- PS> $str = 'string'
272- PS> $str.Length
273- 6
274- PS> $str.Count
275- 1
265+ # Get the length property of each item in the collection.
266+ PS> $collection.GetEnumerator().Length
267+ foo
268+ bar
276269```
277270
278- If a property exists on the individual objects and on the collection, only the
279- collection's property is returned.
280-
281- ``` powershell
282- $collection = @(
283- [pscustomobject]@{length = "foo"}
284- [pscustomobject]@{length = "bar"}
285- )
286- # PowerShell returns the collection's Length.
287- $collection.length
288- ```
289-
290- ``` Output
291- 2
292- ```
271+ For more information, see [ about_Member-Access_Enumeration] [ 01 ] .
293272
294273## See also
295274
296- - [ about_Objects] ( about_Objects.md )
297- - [ about_Member-Access_Enumeration] ( about_Member-Access_Enumeration.md )
298- - [ about_Methods] ( about_Methods.md )
299- - [ Format-List] ( xref:Microsoft.PowerShell.Utility.Format-List )
300- - [ Get-Member] ( xref:Microsoft.PowerShell.Utility.Get-Member )
301- - [ Select-Object] ( xref:Microsoft.PowerShell.Utility.Select-Object )
275+ - [ about_Objects] [ 03 ]
276+ - [ about_Member-Access_Enumeration] [ 01 ]
277+ - [ about_Methods] [ 02 ]
278+ - [ Format-List] [ 04 ]
279+ - [ Get-Member] [ 05 ]
280+ - [ Select-Object] [ 06 ]
281+
282+ <!-- link references -->
283+ [ 01 ] : about_Member-Access_Enumeration.md
284+ [ 02 ] : about_Methods.md
285+ [ 03 ] : about_Objects.md
286+ [ 04 ] : xref:Microsoft.PowerShell.Utility.Format-List
287+ [ 05 ] : xref:Microsoft.PowerShell.Utility.Get-Member
288+ [ 06 ] : xref:Microsoft.PowerShell.Utility.Select-Object
0 commit comments