Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a PowerShell NoteProperty?

Tags:

powershell

The only definition of NoteProperty I've been able to find said they are properties inherited from the PowerShell environment. That doesn't really clarify what they are or how they are used. All the blog posts I've found that reference NoteProperty all seem to assume everyone already knows what they are. "NoteProperty" is even missing from the TechNet PowerShell Glossary.

What is a NoteProperty and how does that differ from a normal property?

like image 843
Simon Tewsi Avatar asked Mar 19 '15 10:03

Simon Tewsi


People also ask

What is script property in PowerShell?

A script property defines a property whose value is the output of a script. In the following example, the VersionInfo property is added to the System. IO. FileInfo type. The ScriptProperty element defines the extended property as a script property.

What is a GET-member?

The Get-Member command uses the Force parameter to add the intrinsic members and compiler-generated members of the objects to the display. You can use these properties and methods in the same way that you would use an adapted method of the object.

What is a PSObject in PowerShell?

Under the hood, all PowerShell objects are PSObject objects All objects that are created in a PowerShell session, be they . NET types, COM objects or the explicit «void» object PSCustomObject , are wrapped into a PSObject, which itself is implemented in the . NET type System. Management. Automation.

What is PS custom object?

PSCustomObject is a great tool to add into your PowerShell tool belt. Let's start with the basics and work our way into the more advanced features. The idea behind using a PSCustomObject is to have a simple way to create structured data. Take a look at the first example and you'll have a better idea of what that means.


2 Answers

NoteProperties are generic properties that are created by Powershell (as opposed to properties that are inherited from a specific dotnet object type).

Properties of PS custom objects will be NoteProperty, as will the properties of objects created with Import-CSV, or created by using Select-Object and specifying properties to select.

like image 144
mjolinor Avatar answered Sep 28 '22 04:09

mjolinor


NoteProperty A property of the object with a static value. Note that properties are defined as a name-value pair, such as "Color=Blue".

Usualy this is use to add a property to a pscustomobject using add-member

see PSMemberTypeEnumeration

like image 30
Loïc MICHEL Avatar answered Sep 28 '22 05:09

Loïc MICHEL