I have created a simple class using Windows PowerShell ISE. The class definition is as follows.
class Person {
[string] $FirstName
[string] $LastName
Person() {
}
[string] Greeting() {
return "Greetings, {0} {1}!" -f $this.FirstName, $this.LastName
}
}
Now from within PowerShell console when I attempt to create an object from this class like this:
$x = [Person]::new()
It says
Unable to find type [Person].
using module?. .\Person.ps1to make the class available in the console. Note the space between the two dots! This is called dot-sourcing. Not the most scalable approach, but easy to use for simple stuff.