Confused about correct naming of Datatypes in PowerShell

Viewed 61

I have a question about PowerShell. I read documentation that datatypes in PowerShell are strings, ints etc. But how would you call the objects that are created for instance when I instantiate an object in PowerShell like so $Object = Get-Process -Name 'NotePad'

What would the correct name be for $object, would this also be called a Data Type?

Kind regards,

John

1 Answers

PowerShell is built using dotnet, an object oriented programming (OOP) framework. Everything in an OOP is an Object, and objects can have many properties.

The properties of an object can be of many different datatypes, like boolean (true false), string( "SomeString") or an int (1). Here's the list of the most common basic datatypes.

Some of the properties might be collections of other rich objects while some could be just string.

So to say is everything in PowerShell a datatype? I can unwind that question to instead ask

What is everything in PowerShell?

Everything in PowerShell is a dotnet object, which might be a single, or a collection of many different datatypes.

In the case of your example.

>(Get-Process notepad).GetType() | 
   Select-Object -ExpandProperty FullName 

System.Diagnostics.Process

PowerShell returns an object which is of the System.Diagnostics.Process datatype.

Related