Home >Tips >PowerShell for object and JSON kalmstrom.com site map icon Site map  

Create Classes, Objects and JSON Files in PowerShell

A tutorial by Peter Kalmstrom

PowerShell iconWith Windows PowerShell you can automate many tedious administration tasks, so PowerShell is a very useful tool for IT professionals. In the demo below Peter Kalmstrom, CEO of kalmstrom.com Business Solutions, shows how to use PowerShell to create classes, objects and JSON files.

In computing, a shell is a user interface that gives access to services in an operating system, thus the name PowerShell. The user interface resembles the command prompt, but PowerShell gives many more options.

Windows PowerShell is included Windows, so anyone can try it. The demo below is however intended for people who already know some about object oriented programming or computer science.

Class and object

To understand how Peter's simple example can be built out and used for more advanced processes, it is important that you understand the difference between a class and an object:
  • A class is written by a programmer. The class describes an object and tells how the object can be manipulated.

  • An object is the computer's representation of the class, and it exists when the program is run.


In the demo below Peter uses a classical "car" example to show how to do the following in PowerShell:
  • Define a class "Car", and set its properties.

  • Create an object "My Car" based on the class "Car" and set its propertiy values.

  • Run the script. This is done by selecting what should be run and pressing F8.

  • Check the object's property values.

  • Convert the object to a JSON file and add it to a directory.

kalmstrom.com Services

Do you need assistance in creating a PowerShell script that performs complicated operations quickly and correctly? Contact kalmstrom.com and describe what you want to do, and we will give you a quote!


Always the latest news in the kalmstrom.com blog

Follow kalmstrom.com on
LinkedIn Facebook, Google+ or Twitter!

Products Buy FAQ Services Tips Books Contact About Us Blog

Security and integrity

Copyright  Kalmstrom Enterprises AB  All rights reserved