-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

PowerShell 7 Workshop
By :

In the last section, we talked about types of variables. Now, we’re going to talk about object types – the things that go in the box. The type of the object in the variable tells the computer what to do with it – what properties it has and what we can do with it. Type the following:
$MyVariable = "some stuff" $MyVariable | Get-Member
We should see something like the output in Figure 4.6:
Figure 4.6 – It’s a string
We’ve put a string in there, and we know this because we’re told it – TypeName
is System.String
. At the moment, MyVariable
contains a string. We can change what the type is by assigning something else to it. Try typing the following without quotation marks:
$MyVariable = 4.2
Then, use Get-Member
to check the contents. Now we’ve got a System.Double
object type in there, a floating-point number.
We can do even better things. Type the following...
Change the font size
Change margin width
Change background colour